Nerd Tree: A File Explorer with Mac Vim

The one thing missing from the great text editor that is Mac Vim is a project / file explorer side bar. Competing text editors such as Sublime and Text Mate have one, so why not MacVim? It doesn't seem like it would require too much additional work of the developers. Reading through debates the community has had on the issue, the reason appears to be the elitist and idealistic nature of the Mac Vim community. Please don't read that last sentence pejoratively; these guys are purists, and very good at what they do. There were quite a few in the community who believed NERDTree was more than enough for any code jocky's needs, so I decided to checkout what all the fuss was about.

I use pathogen to manage vim plugins, and it is especially useful in conjunction with a public source control system like github. Once you have pathogen installed simply pull the NerdTree Github project to your vim plugins directory.

cd ~/.vim/bundle
git clone git://github.com/scrooloose/nerdtree.git


Next add a shortcut to make opening your NERDTree more convenient by adding the following to your vim config file (~/.vimrc)

" Give a shortcut key to NERD Tree
map <F2> :NERDTreeToggle<CR>


Now fire up your MacVim, open a window, and press (fn+F2).
With NerdTree now started, the following commands should get you going:

  • Use the natural vim navigation keys hjkl to navigate the files, or just the arrow keys

  • Press o to open the file in a new buffer or open/close directory.

  • Press t to open the file in a new tab.

  • Press i to open the file in a new horizontal split.

  • Press s to open the file in a new vertical split.

  • Press p to go to parent directory.

  • Press r to refresh the current directory.



Tip:
Open a project with mvim + nerdtree from the command line like this:
mvim ~/Dev/path/to/project



Happy Coding!

References:
http://www.catonmat.net/blog/vim-plugins-nerdtree-vim
http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen
http://wiredupandfiredup.blogspot.com/2008/09/pimp-your-macvim.html

Comments

Popular posts from this blog

AngularJs: User friendly date display with AngularJs and MomentJs

Getting started with Grails functional tests using Geb + Spock