Question

Currently the NERDTree buffer opens for every file that you open. If I'm writing to *.scala, *.py, etc. But I don't want this to happen for certain files that I'm writing (such as Haskell). For example, when I'm opening a Haskell file, I don't want the NERDTree buffer to open as soon as I type in vim file.hs in the terminal. Does anyone know how to get this to work?

Was it helpful?

Solution

You probably use something like this in your ~/.vimrc to automatically open NERDTree:

:autocmd VimEnter * NERDTree

You just need to add a conditional, e.g. to suppress the opening when any files are passed to Vim:

:autocmd VimEnter * if argc() == 0 | NERDTree | endif

As the VimEnter command fires after buffers have been loaded, you can also check for the current 'filetype' value to suppress only, say, Haskell files:

:autocmd VimEnter * if &filetype !=# 'haskell' | NERDTree | endif
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top