How can I use gvim for svn commit messages under Windows?

拈花ヽ惹草 提交于 2019-12-22 04:31:14

问题


Under *nix I can set SVN_EDITOR to gvim --nofork to do the trick, but that doesn't seem to work under Windows. Is there any solution for that?


回答1:


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.




回答2:


This answer was written for Git, but should directly apply.

To make this work, try the following.

  1. Create a one-line batch file (named svn_editor.bat) which contains the following:
  2. "path/to/gvim.exe" --nofork "%*"
  3. Place svn_editor.bat on your PATH.
  4. 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.




回答3:


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


来源:https://stackoverflow.com/questions/4681665/how-can-i-use-gvim-for-svn-commit-messages-under-windows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!