8

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.

  • Do you really need that window open at all times? – romainl Feb 19 '13 at 20:27
7

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.