Loading ...
Sorry, an error occurred while loading the content.

53898RE: vimrc on windows

Expand Messages
  • David Fishburn
    Sep 30, 2004
    • 0 Attachment
      > > Oh, I see. And I tend to forget that in CMD.EXE I have to
      > 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

      Tony, thanks for the tip about AutoRun, didn't know about that one.

      You also have some path/file name completion abilities with a standard
      cmd.exe shell.
      This can be enabled 2 ways:
      HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\CompletionChar =
      Hex(9).
      Allows you to use the Tab key to complete (like in Vim) filenames and paths.

      Or you can start the cmd.exe with:
      %SystemRoot%\system32\cmd.exe /F:ON

      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
      Start menu.

      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
      machines.
      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
      doskey.

      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
      support.

      If this is of worth to anyone, wonderful.


      doskey.mac
      ***************
      u=cd ..
      u2=cd ..\..
      u3=cd ..\..\..
      u4=cd ..\..\..\..
      u5=cd ..\..\..\..\..
      s=start $*
      n=notepad.exe $*
      dir=dir /p /ogn /a: $*
      o=cd ..\$1
      cd=set LastDir=%cd% $T chdir /d $*
      t=set NextDir=%LastDir% $T set LastDir=%cd% $T chdir /d %NextDir%
      e=explorer .
      ***************


      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
      @SET driveletter=%cmd_driveletter

      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.


      setupVim.bat
      ***************
      @echo on

      @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
      @rem
      for /f %%i in ("%0") do @SET cmd_driveletter=%%~di
      @SET driveletter=%cmd_driveletter

      @echo.
      @echo Executing %0 from this drive: %cmd_driveletter%
      @echo.

      @IF %1. NEQ . SET driveletter=%1:
      @IF NOT EXIST %driveletter%\ SET driveletter=%cmd_driveletter%

      :SETPATH
      @echo.
      @echo. Check if Vim is already in the PATH
      @echo.
      which gvim.exe
      @IF %errorlevel% EQU 0 GOTO SETDOSKEY

      @echo.
      @echo. Setup path to include $VIM and other standard utilities
      @echo.
      SET
      PATH=%driveletter%:\vim\tools;%driveletter%:\Vim\Vim63;%driveletter%:\util;%
      driveletter%:\util\unix_tools;%PATH%

      :SETDOSKEY
      @rem
      @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
      @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
      @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
      file
      @rem instead of replacing the data in the file. These double characters
      @rem are equivalent to the append redirection symbol for output (>>).
      @rem
      @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.
      This
      @rem character is equivalent to the redirection symbol for input (<).
      @rem
      @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
      @rem $T or $t - Separates commands. Use either of these special characters
      @rem to separate commands when you create macros or type commands on
      the
      @rem doskey command line. These special characters are equivalent to
      using
      @rem the ampersand (&) on a command line.
      @rem
      @rem $$ - Specifies the dollar-sign character ($).
      @rem
      @rem $1 through $9 - Represent any command-line information you want to
      @rem specify when you run the macro. The special characters $1 through
      $9
      @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.
      The
      @rem $1 character in a doskey command is similar to the %1 character in
      a
      @rem batch program.
      @rem
      @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
      the
      @rem command line after the macro name is substituted for the $* in the
      @rem macro.
      @rem
      @rem To create a doskey macro for a program called Ftp.exe, include
      /exename
      @rem as follows:
      @rem doskey /exename:ftp.exe go=open 10.127.1.100$tmget *.TXT
      c:\reports$bye
      @rem

      doskey /reinstall /listsize=100
      /macrofile=%driveletter%\vim\tools\doskey.mac

      @rem
      @rem Display current macros
      @rem
      doskey /macros

      @echo.
      @echo.
      @echo. DOSKEY Special Keys
      @echo. -------------------
      @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
      session.
      @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
      to,
      @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
      to
      @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
      select
      @echo. the command you want, and press ENTER to run the command. You
      can
      @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
      history
      @echo. buffer.
      @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
      the
      @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.
      @echo. For more detailed information see:
      @echo.
      http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-
      us/doskey.mspx
      @echo.

      ***************


      Enjoy.
      Dave

      --
      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
      databases (http://www.vim.org/scripts/script.php?script_id=492)
      sql.vim - SQL indent file for Sybase ASA and Oracle
      (http://www.vim.org/scripts/script.php?script_id=495)
      Intellisense for Vim : SQL, C++, CSharp, Java, JSP, XML, HTML
      (http://www.vim.org/scripts/script.php?script_id=747)
    • Show all 24 messages in this topic