@Björn Winckler 的回答向您展示了如何对通过 finder 和其他操作系统打开机制打开的文件执行此操作。
如果您希望它与 mvim 命令一起使用,请找到 mvim 文件并从
更改底部的行
if [ "$gui" ]; then
# Note: this isn't perfect, because any error output goes to the
# terminal instead of the console log.
# But if you use open instead, you will need to fully qualify the
# path names for any filenames you specify, which is hard.
exec "$binary" -g $opts ${1:+"$@"}
else
exec "$binary" $opts ${1:+"$@"}
fi
到
if [ "$gui" ]; then
# Note: this isn't perfect, because any error output goes to the
# terminal instead of the console log.
# But if you use open instead, you will need to fully qualify the
# path names for any filenames you specify, which is hard.
#make macvim open stuff in the same window instead of new ones
if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
exec "$binary" -g $opts --remote ${1:+"$@"}
else
exec "$binary" -g $opts ${1:+"$@"}
fi
else
exec "$binary" $opts ${1:+"$@"}
fi
这将使从命令行打开的所有文件也在同一个窗口中打开。
此外,如果您希望该文件在该文件已打开的情况下打开相同的缓冲区,而不是拆分或添加新选项卡
au VimEnter,BufWinEnter * NERDTreeFind 到你的 gvimrc(这样就不会干扰你的常规 vim)
(最后一部分需要您安装 NERDTree)