Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Nice and simple, I'd like for NERDTree not to get involved when vim is invoked by git, for example when authoring a commit message or dealing with a rebase.

Presumably this is achievable by way of some kind of filetype detection (gitcommit etc), but precisely how to do it I have no idea. The relevant parts of my vimrc at the moment are:

autocmd vimenter * NERDTree
map <C-n> :NERDTreeToggle<CR>

I wish to retain the auto-opening of NERDTree in the general case. I've tried something along the lines of:

autocmd FileType gitcommit NERDTreeToggle

However the docs would suggest VimEnter as pretty much the last thing to fire after all buffers have been loaded etc, so I guess that's why this doesn't work.

Thanks in advance.

share|improve this question
Do you really need that window open at all times? – romainl Feb 19 '13 at 20:27
up vote 2 down vote accepted

I think you already have all the pieces together: Just combine the launch of NERDTree with a conditional on the filetype; when VimEnter fires, this should already be set:

:autocmd VimEnter * if &filetype !=# 'gitcommit' | NERDTree | endif
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .