How can I use gvim for svn commit messages under Windows?
Under *nix I can set SVN_EDITOR
to gvim --nofork
to do the trick, but that do开发者_如何学运维esn't seem to work under Windows. Is there any solution for that?
If you have installed the batch files (c:\windows\gvim.bat), just set EDITOR
to gvim -f
, the batch file processes the -f argument and sets the no-fork option.
The trick in the batch file is running START /WAIT path\to\gvim.exe %*
(see the /WAIT argument).
If you don't have the batch files, just create a new one with the command above, and set EDITOR
to the newly create batch file.
This answer was written for Git, but should directly apply.
To make this work, try the following.
- Create a one-line batch file (named
svn_editor.bat
) which contains the following: "path/to/gvim.exe" --nofork "%*"
- Place
svn_editor.bat
on yourPATH
. - Set
SVN_EDITOR=svn_editor.bat
With this done, SVN should correctly invoke the gvim executable.
NOTE 1: The --nofork option to gvim insures that it blocks until the commit message has been written.
NOTE 2: The quotes around the path to gvim is required if you have spaces in the path.
NOTE 3: The quotes around "%*" are needed just in case git passes a file path with spaces.
If the problem is passing parameters to prevent forking to gvim (your question was a little vague), then you can either create a batch file that calls gvim with the required parameters or you could simply add the following to your vimrc
(NOT gvimrc
) and point SVN_EDITOR
at gvim.exe
:
set guioptions+=f
This tells vim not to fork when creating the GUI and has the advantage of not having to mess around with batch files. For more information, see:
:help gui-fork
精彩评论