tags:

views:

2751

answers:

2

How do you do it?

+4  A: 

Are you on a Windows or unix-y system?

If you're on a unix-y system you put plugins in ~/.vim/plugin. Here's what my plugin directory looks like:

$ ls ~/.vim/plugin
NERD_tree.vim  scratch.vim  scratchfind.vim

After that it starts working right away. Try running vim like this:

$ vim .

It should open the current directory in the NERD tree view.

If you're on Windows you put plugins here: C:\Program Files\Vim\vim70\plugin


To get NERDTree to load automatically when you start up vim, run it like this from the command line:

$ vim -c "NERDTree" some_file.txt

You can set an alias for this in your .bashrc:

alias vimt='vim -c "NERDTree" $1'

Now whenever you run vimt (instead of vim) you'll also open up NERDTree on the left side of the window.

You could also add a shortcut key to start NERDTree in your .vimrc this way:

function OpenNERDTree()
  execute ":NERDTree"
endfunction
command -nargs=0 OpenNERDTree :call OpenNERDTree()

nmap <ESC>t :OpenNERDTree<CR>

Now when you hit Esc then t it will pop open NERDTree.

lost-theory
I'm running a Unix-y machine. I have NERDTree Installed, what I need is to have NERDTree to start when I type vim in the commandline. So that a file browser always opens to the left, like in Textmate. I don't know what to put into the vimrc to do this, I tried :NERDTree but it does not seem to recognise the command...
chutsu
Thought I'd add that there is a :NERDTreeToggle built in mapping you can map to which makes your custom function rather redundant.
Gavin Gilmour
+16  A: 

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. The line below does this.

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, like so:

autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
Douglas Mayle