I've been using Vim now for most of my editing for the last week or so and I'm loving the experience. However I have an issue.
I've setup my .vimrc
file with NERD_tree
and a few other goodies. This works well for when I'm coding. However on occasion I use vimdiff
via Git and this causes some problems. I don't need NERD_Tree
open when I do this or many of the other things I've setup in my .vimrc
file.
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? Specifically how do I test to see if vimdiff
i开发者_如何学Pythons the caller? Or am I going about this entirely the wrong way?
Excerpt from the VIM manual called up by typing in :h diff
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.
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.
精彩评论