Download and configure
The official address of the Nerdtree plugin is as follows, and you can get the latest version from here
Https://github.com/scrooloose/nerdtree Download Zip installation package
Or use the following official website source file installation method
My lab environment is centos6.6, and the other versions may be a little different.
Installation method is very simple, first download the compressed file, unzip the plugin directory under the Nerd_tree.vim copy ~/.vim/plugin and the nerd_tree.txt copy of the doc directory to ~/.vim/doc. ~ Represents the current user's directory, My environment does not have ~/.vim ~/.vim/plugin ~/.vim/doc, will be created later, if your version has, it is better.
After installation, enter VIM on the command line, open vim, enter in vim: Nerdtree, you can see the effect of nerdtree.
For the sake of convenience, let's set up a shortcut key to add the following to the ~/.VIMRC file.
My centos6.6 still does not have this ~/.VIMRC, it doesn't matter, create a, direct
vim ~/.vimrc
And then add
<F10> :NERDTreeToggle<CR>
When you turn on VIM, you can display and hide Nerdtree file browsing by pressing F10 on the keyboard.
Only will F10, that also too no technical content, below is another wave of shortcut keys, learn it.
Shortcut
Switching tables and directories
ctrl + w + h cursor focus tree tree on the left
ctrl + w + l cursor focus right file display window
ctrl + w + w Cursor switch between left and right windows automatically
ctrl + w + r move the layout position of the current window
o Open a file, directory or bookmark in an existing window and jump to that window
go Open a file, directory, or bookmark in an existing window without jumping to it
t Open selected file / bookmark in new tab and jump to new tab
T Open selected file / bookmark in new tab without jumping to new tab
i split opens a new window with the selected file and jumps to that window
gi split opens a new window with the selected file, but does not jump to that window
s vsplit Open a new window with the selected file and jump to that window
gs vsplit Opens a new file in a new window without jumping to it
! Execute the current file
O Recursively open all directories under the selected node
x collapse the parent directory of the selected node
X recursively collapse all directories under the selected node
e Edit the current dif
Double-click equivalent to NERDTree-o
Middle key is equivalent to NERDTree-i for files and NERDTree-e for directories
D Delete the current bookmark
P jump to root node
p jump to parent node
K jump to the first node of the same level in the current directory
J jump to the last node of the same level in the current directory
k jump to the previous node of the same level in the current directory
j jump to the next node of the same level in the current directory
C Set the selected directory or the parent directory of the selected file as the root node
u Set the parent directory of the current root node as the root directory, and turn it into the original root node.
U Set the parent directory of the current root node as the root directory, but keep expanding the original root node
r recursively refresh the selected directory
R recursively refresh the root node
m Display the file system menu
cd Make CWD the selected directory
I Toggle whether to show hidden files
f whether to use file filters
F Switch whether to display files
B Toggle whether to show bookmarks
q Close the NerdTree window
? Toggle whether Quick Help is displayed
Toggle tab Page
: tabnew [++ opt option] [+ cmd] File Create a new tab for the specified file
: tabc close the current tab
: tabo close all other tabs
: tabs View all open tabs
: tabp previous tab
: tabn next tab
Standard mode:
gT previous tab
gt next tab
MacVim can also use shortcut keys to close and switch tabs
cmd + w close the current tab
cmd + {previous tab
cmd +} next tab
NerdTree common configuration in .vimrc
"Nerdtree is turned on by default when Vim is started (Autocmd can be abbreviated as AU)
* NERDTree
"Press F2 to bring up/hide Nerdtree
map :silent! NERDTreeToggle
"Set the Nerdtree window to the right of the Vim window (default to the left)
let NERDTreeWinPos="right"
"When you open the Nerdtree window, the Bookmarks is displayed automatically
let NERDTreeShowBookmarks=1
Vim tree-like file list Nerdtree