53898RE: vimrc on windows
- Sep 30, 2004
> > Oh, I see. And I tend to forget that in CMD.EXE I have toTony, thanks for the tip about AutoRun, didn't know about that one.
> use /A: to
> > see the full contents, hidden or not (on my former system I ueds
> > NDOS.COM, a clone of 4DOS.COM, and there I could tell it
> once and for
> > all that I always wanted to see them). On Unix I seem to
> remember ls
> > -a somewhat more easily -- and I can use aliases.
> For the 'dir' command, you can set the DIRCMD environment
> variable to contain whatever flags you want to use by
> default. See the output of
> help dir
> in a CMD.EXE prompt.
> > Does CMD.EXE know anything similar to the "alias" command
> of bash and
> > 4DOS? It'd be useful. (I already found out about
> > [HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER]\Software\Microsoft\Command
> > Processor\AutoRun and set it to run a BAT script of my
> choice when it
> > starts up. I don't like editing the registry but in this case it
> > seemed simple enough -- and it works AFAICT)
> From the CMD.EXE prompt, type
> help doskey
You also have some path/file name completion abilities with a standard
This can be enabled 2 ways:
HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar =
Allows you to use the Tab key to complete (like in Vim) filenames and paths.
Or you can start the cmd.exe with:
I didnt like this as much since it uses 2 different keys for completing
directories vs files. It also meant I had to launch cmd.exe with
parameters, which is a pain, since I usually just use the Run menu from the
So I have an icon to do this, but now with Tony's AutoRun, I dont worry
about this one either.
%SystemRoot%\system32\cmd.exe /K c:\vim\tools\setupvim.bat
At the last customer site I visited I found some of this out, and was given
a very good idea (IMO).
I have a USB key, which I use to transfer files back and forth between
Now, I keep my Vim directory on it.
I have a batch file that will allow me to sit at anyones machine, plug in my
USB key and basically have my usual environment.
So I have my Vim, all the tools I use with Vim (cscope, ctags, xml stuff,
tidy, ...) and doskey for my usual macros. Like Tony, on my laptop I use
4NT as my shell, and I really missed my aliases, but I have them now with
So I created the setupVim.bat file and my doskey macro file, I have included
the contents of both since I documented them and wanted to show a couple of
examples for macros.
I am running WinXP, this should also work fine on W2K.
For Win ME, 98 and so on, I do not believe the FOR statement has the same
If this is of worth to anyone, wonderful.
dir=dir /p /ogn /a: $*
cd=set LastDir=%cd% $T chdir /d $*
t=set NextDir=%LastDir% $T set LastDir=%cd% $T chdir /d %NextDir%
With this routine, I wanted to be able to run it either from my desktop, or
from the USB key, so I did some funky work at the top with:
for /f %%i in ("%0") do @SET cmd_driveletter=%%~di
This allows me to figure out what drive letter I am running the bat file
from. Then I know where to load the macro file from as well. It is just a
bit more user friendly.
@rem You can have Windows automatically run a batch file when you open
@rem a new command prompt by:
@rem HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun
@rem and set it to run a BAT script of your choice when it
@rem starts up.
@rem Determine which drive letter we are executing this from:
@rem % 0 = the cmdline used to launch the cmd file.
@rem for /f %%i in ('echo %0') do @echo curr_dir=%%~di
@rem From HELP FOR (when typed from a cmd.exe prompt)
@rem You can now use the following optional syntax:
@rem % ~I - expands %I removing any surrounding quotes (")
@rem % ~fI - expands %I to a fully qualified path name
@rem % ~dI - expands %I to a drive letter only
for /f %%i in ("%0") do @SET cmd_driveletter=%%~di
@echo Executing %0 from this drive: %cmd_driveletter%
@IF %1. NEQ . SET driveletter=%1:
@IF NOT EXIST %driveletter%\ SET driveletter=%cmd_driveletter%
@echo. Check if Vim is already in the PATH
@IF %errorlevel% EQU 0 GOTO SETDOSKEY
@echo. Setup path to include $VIM and other standard utilities
@rem doskey allows you to create macros for common commands
@rem This allows me to create 4NT like aliases or Unix aliases
@rem General format from the command line is:
@rem doskey u=cd ..
@rem doskey dir=dir /o /ogn $*
@rem doskey o=cd ..\$1
@rem doskey cd=set LastDir=%cd% $T chdir /d $*
@rem $G or $g - Redirects output. Use either of these special characters to
@rem send output to a device or a file instead of to the screen. This
@rem character is equivalent to the redirection symbol for output (>).
@rem $G$G or $g$g - Appends output to the end of a file. Use either of
@rem these special double characters to append output to an existing
@rem instead of replacing the data in the file. These double characters
@rem are equivalent to the append redirection symbol for output (>>).
@rem $L or $l - Redirects input. Use either of these special characters to
@rem read input from a device or a file instead of from the keyboard.
@rem character is equivalent to the redirection symbol for input (<).
@rem $B or $b - Sends macro output to a command. These special characters
@rem are equivalent to using the pipe (|) on a command line.
@rem $T or $t - Separates commands. Use either of these special characters
@rem to separate commands when you create macros or type commands on
@rem doskey command line. These special characters are equivalent to
@rem the ampersand (&) on a command line.
@rem $$ - Specifies the dollar-sign character ($).
@rem $1 through $9 - Represent any command-line information you want to
@rem specify when you run the macro. The special characters $1 through
@rem are batch parameters, which make it possible for you to use
@rem different data on the command line each time you run the macro.
@rem $1 character in a doskey command is similar to the %1 character in
@rem batch program.
@rem $* - Represents all the command-line information you want to specify
@rem when you type the macro name. The special character $* is a
@rem replaceable parameter that is similar to the batch parameters $1
@rem through $9, with one important difference: everything you type on
@rem command line after the macro name is substituted for the $* in the
@rem To create a doskey macro for a program called Ftp.exe, include
@rem as follows:
@rem doskey /exename:ftp.exe go=open 10.127.1.100$tmget *.TXT
doskey /reinstall /listsize=100
@rem Display current macros
@echo. DOSKEY Special Keys
@echo. UP ARROW - Recalls the command you used before the one displayed.
@echo. DOWN ARROW - Recalls the command you used after the one displayed.
@echo. PAGE UP - Recalls the oldest command you used in the current
@echo. PAGE DOWN - Recalls the most recent command you used.
@echo. HOME - Moves the insertion point to the beginning of the line.
@echo. END - Moves the insertion point to the end of the line.
@echo. ESC - Clears the command from the display.
@echo. LEFT ARROW - Moves the insertion point back one character.
@echo. RIGHT ARROW - Moves the insertion point forward one character.
@echo. CTRL+LEFT ARROW - Moves the insertion point back one word.
@echo. CTRL+RIGHT ARROW - Moves the insertion point forward one word.
@echo. F1 - Copies one character from the same column in the template to the
@echo. same column in the Command Prompt window. (The template is a
@echo. memory buffer that holds the last command you typed.)
@echo. F2 - Searches forward in the template for the next key you type after
@echo. pressing F2. Doskey.exe inserts the text from the template up
@echo. but not including, the character you specify.
@echo. F3 - Copies the remainder of the template to the command line.
@echo. Doskey.exe begins copying characters from the position in the
@echo. template that corresponds to the position indicated by the
@echo. insertion point on the command line.
@echo. F4 - Deletes characters from the current insertion point position up
@echo. a character you specify. To use this editing key, press F4 and
@echo. type a character. Doskey.exe deletes the characters from the
@echo. current insertion point position to the first letter specified.
@echo. F5 - Copies the template into the current command line.
@echo. F6 - Places an end-of-file character (that is, CTRL+Z) at the current
@echo. insertion point position.
@echo. F7 - Displays all commands for this program stored in memory in a
@echo. pop-up box. Use the UP ARROW key and the DOWN ARROW key to
@echo. the command you want, and press ENTER to run the command. You
@echo. also note the sequential number in front of the command and use
@echo. this number in conjunction with the F9 key.
@echo. ALT+F7 - Deletes all commands stored in memory for the current
@echo. F8 - Displays all commands in the history buffer that start with the
@echo. characters in the current command.
@echo. F9 - Prompts you for a history buffer command number, then displays
@echo. command associated with the number you specify. Press ENTER to
@echo. run the command. To display all the numbers and their associated
@echo. commands, press F7.
@echo. ALT+F10 - Deletes all macro definitions.
@echo. For more detailed information see:
Do you use Vim to edit SQL?
Check the description of these plugins:
dbext.vim - Provides database access to 10 databases (Oracle, Sybase, SQL
Server, MySQL,...) (http://www.vim.org/scripts/script.php?script_id=356)
SQLUtilities - Formatting SQL, generate - columns lists, procedures for
sql.vim - SQL indent file for Sybase ASA and Oracle
Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
- << Previous post in topic Next post in topic >>