Exploring files and directories in vim with the NERD tree plugin

Warning: This blog post was written a long time ago and might be no longer relevant.

Exploring, opening, switching, renaming, moving files and directories are common tasks performed during coding. In IDEs it is usually achieved with some kind of filesystem explorer. In vim I preffer to use the NERD tree plugin.

NERD tree plugin for vim

NERD Tree features

NERD tree enables you to:

  • Navigate and jump through the directory tree
  • Open files in the current window, tab, split view (horizontal and vertical)
  • Change the current working directory
  • Add, move, copy and remove files and directories
  • Filter the tree
  • Create the bookmarks

Installation

Get the source from the plugin website and unzip it into your ~/.vim directory.

To make using NERD tree more convenient it's best to create a shortcut mapping. To use ctrl+n add the following line to your ~/.vimrc file:

nmap <silent> <c-n> :NERDTreeToggle<CR>

Usage

Run vim and type :NERDTreeToggle or ctrl+n. The later will work only if you've created a mapping. NERD tree should open and present you the directory structure.

I'd suggest you to start with pressing the ? to read a quick help and learn about the plugin features.