Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using vimdiff with a different .vimrc?

Tags:

vim

diff

vimdiff

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 .vimrcfile 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 is the caller? Or am I going about this entirely the wrong way?

like image 612
Brent Taylor Avatar asked Dec 22 '09 06:12

Brent Taylor


2 Answers

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
like image 124
Daniel Bruce Avatar answered Oct 30 '22 10:10

Daniel Bruce


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.

like image 26
Zac Thompson Avatar answered Oct 30 '22 08:10

Zac Thompson