[英]Using vimdiff with a different .vimrc?
I've been using Vim now for most of my editing for the last week or so and I'm loving the experience. 在过去一周左右的时间里,我一直在使用Vim进行大部分编辑,我很喜欢这种体验。 However I have an issue. 但是我有一个问题。
I've setup my .vimrc
file with NERD_tree
and a few other goodies. 我用NERD_tree
和其他一些东西设置了我的.vimrc
文件。 This works well for when I'm coding. 这适用于我编码的时候。 However on occasion I use vimdiff
via Git and this causes some problems. 但有时我通过Git使用vimdiff
,这会导致一些问题。 I don't need NERD_Tree
open when I do this or many of the other things I've setup in my .vimrc
file. 当我执行此操作或我在.vimrc
文件中设置的许多其他内容时,我不需要打开NERD_Tree
。
Here's my question. 这是我的问题。 Is there a way to check what is calling my .vimrc file and have it execute different code depending on the caller? 有没有办法检查调用我的.vimrc文件是什么,让它根据调用者执行不同的代码? Specifically how do I test to see if vimdiff
is the caller? 具体来说,我如何测试vimdiff
是否是调用者? Or am I going about this entirely the wrong way? 或者我完全以错误的方式解决这个问题?
Excerpt from the VIM manual called up by typing in :h diff
通过键入:h diff
来调出VIM手册
if &diff
setup for diff mode
else
setup for non-diff mode
endif
Definitely you want to use Daniel Bruce's solution -- I suspect you always want a different configuration for vimdiff than for vim, whether git is in the picture or not. 肯定你想要使用Daniel Bruce的解决方案 - 我怀疑你总是想要一个不同于vimdiff的配置而不是vim,无论git是否在图片中。
But if you want particular behaviour for vimdiff when used with git as opposed to standalone, you can instead use a wrapper script for your gitconfig [diff] external
, and the script could select a different rc file altogether. 但是如果你想在使用git而不是独立时使用vimdiff的特定行为,你可以使用gitconfig [diff] external
的包装器脚本,脚本可以完全选择不同的rc文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.