I have been working on Rails for more than half year and i do file editing with vi at server side most of the time. vi is a great tool but it is not convenient for editing multiple files which is very common in programmer. In the past, I had to close the file, cd to another directory and opened another file for editing.
And last week, Steve told me a vi plugin called NERDTree which acts like a File Explorer in vi and it is written by Marty Grenfell. I have just tried it and it definitely changed my life! Let’s install it first.
1. Download the plugin from the NERDTree website to ~/.vim
2. Unzip the downloaded archive
3. Open vi
4. Enter :helptags ~/.vim/doc
5. Restart vi
Now you can open the NERDTree Explorer by the :NERDTree command.
Here are some the useful commands and hotkeys i found in a blog post written by Peteris Krumins and StackOverflow.
COMMANDS
:NERDTree #Open the NERDTree Explorer :NERDTreeClose #Close the NERDTree Explorer :tabp #Go to previous vi tab :tabn #Go to next vi tab :tabnew #Open new vi tab
HOTKEYS
o #Open file or directory in the NERDTree Explorer t #Open file in new vi tab i #Open file in new horizontal split s #Open file in new vertical split p #Go to parent directory r #Refresh current directory ctrl+ww #Switch between the NERDTree Explorer and File Buffer
Done =)
Reference:
4 thoughts on “NERDTree – The File Explorer in vi/vim”