问题描述
有没有办法让 gVim 只运行一个实例,这样当用它打开一个新文件时,它会自动在当前运行的实例的新选项卡中打开?
Is there a way to let gVim only run a single instance, so that when a new file is opened with it it's automatically opened in a new tab in the currently running instance?
我知道您可以通过传递 --remote-tab-silent
来做到这一点,但我想配置 gvim,使其成为默认行为.即我想输入 gvim 文件名
并让它像我传递了 --remote-tab-silent
选项一样.
I know you can do that by passing --remote-tab-silent
but I want to configure gvim so that this becomes the default behavior. i.e. I want to type gvim filename
and make it act as if I passed the --remote-tab-silent
option to it.
gVim 7.2
我在 windows (vista) 上
I'm on windows (vista)
推荐答案
如果你使用的是 bash shell(在 Linux/OS X 上/使用 Cygwin)是添加你的 ~/.bashrc
文件:
If you are using the bash shell (on Linux/OS X/using Cygwin) is to add you ~/.bashrc
file:
gvim () { command gvim --remote-silent "$@" || command gvim "$@"; }
在 Windows 上,我认为您可以使用 gvim.bat
批处理脚本来实现相同的效果..
On Windows I think you could have a gvim.bat
batch-script to achieve the same..
gvim.exe -p --remote-tab-silent %1 %*
如果 gvim.exe 不在您的路径中
If gvim.exe isn't in your path
Run > Search "Environment"
为当前用户或系统编辑 PATH var.
Edit PATH var for current user or system.
这篇关于让 gVim 始终运行单个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!