NERDTree – file and directory navigator for VIM

I used to code on Windows using e-texteditor. I find e it’s very useful and light weight, that’s why I like it.

Recently I have to switch to CentOS, so I begin to code using Vim. After hours searching on the Internet, I found NERDTree, a Vim plugin that makes Vim very comfortable. NERDTree provides a folder tree on the left hand side for you to navigate. Moreover you can set your personal options to make your own working enviorenment.

Personally, after setting these options, I think Vim on Centos becomes e-texteditor on Windows, which is my favorite editor.

 

Vim with NERDTree plugin
Vim with NERDTree plugin

 

You can download NERDTree here:
http://www.vim.org/scripts/script.php?script_id=1658
or:
http://github.com/scrooloose/nerdtree

– extract the .zip file to ~/.vim
– enter Vim and enter “:NERDTree” to show folder

Add these options to your .vimrc file to customize NERDTree:

map <C-l> gt " shortcut for next tab
map <C-h> gT " previous tab
map <C-n> :tabnew " new tab

autocmd VimEnter * NERDTree ” enter NERDTree automatically when entering VIM
autocmd BufEnter * NERDTreeMirror ” add folder tree to the left hand side for each tab
autocmd VimEnter * wincmd p ” not sure, seems to add color :D

Have fun.

2 thoughts on “NERDTree – file and directory navigator for VIM

  1. “wincmd p” will move the cursor to the previous (last accessed) window.

    So you will have focus not on the NERDTree but on the opened file buffer (if any given) or a new buffer if none is given.

    • You’re right. I don’t find this useful as with this option, everytime I open up Vim it will show up the directory tree on the left and the cursor on the right, which is a empty area. Moreover, I believe all of us will have to switch back to tree to select the file we want to open.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s