Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable NERDTree buffer when opening certain file types

Tags:

vim

nerdtree

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?

like image 420
Petesta Avatar asked Dec 20 '13 18:12

Petesta


1 Answers

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
like image 101
Ingo Karkat Avatar answered Oct 29 '22 07:10

Ingo Karkat