Search code examples
vimnerdtree

How to add NERDTree to your .vimrc


How do I add NERDTree to my .vimrc?


Solution

  • Okay, the previous version was a bit terse, but the answer you're looking for is to add the line below into your ~/.vimrc file. It tells Vim that you want to setup a command to run when Vim starts, but since it depends on various plugins to be loaded, you don't want to run it until all initialization is finished:

    autocmd VimEnter * NERDTree
    

    If, however, you're annoyed by the fact that the cursor always starts in the NERDTree window, you can add a second autocommand that will move the cursor into the main window:

    autocmd VimEnter * NERDTree
    autocmd VimEnter * wincmd p