10

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.

1
  • Do you really need that window open at all times?
    – romainl
    Feb 19, 2013 at 20:27

1 Answer 1

10

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

You must log in to answer this question.

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