How to elegantly use the VIM file management plugin NERDTree

Abstract: I believe that all students who use vim know the file management plug-in NERDTree. This plug-in is used by almost all developers who support vim, but when I first started using it, I used this plug-in completely wrong, and it was a burden to use. . Today, I will summarize how to use NERDTree elegantly.

I believe that all students who use vim know the file management plug-in NERDTree. This is a plug-in used by almost all developers who support vim, but when I first started using it, I used this plug-in completely wrong, and it was a burden to use. Today, I will summarize how to use NERDTree elegantly.

Installation and basic
usage It is recommended to use Vundle to install the plugin. The usage of Vundle is very simple, you can check it on GitHub.

Some basic operations in the NERDTree operation area:

?: Quick help documentation
o: Open a directory or open a file, create a buffer, and can also be used to open bookmarks
go: Open a file, but the cursor remains in NERDTree, create a buffer
t: Open a file, create a Tab, which is also valid for
bookmarks
buffer
gi: split the window for creating files horizontally, but the cursor still stays in NERDTree
s: split the window for creating files vertically, create buffer
gs: and gi, go is similar to
x: close the currently opened directory
X: close all open Directory
e: Open the selected directory in file management mode
D: Delete bookmark
P: Uppercase, jump to the current root path
p: Lowercase, jump to the previous path where the cursor is located
K: Jump to the first sub-path
J : Jump to the last sub-path
<Cj> and <Ck>: Move between directories and files at the same level, ignoring sub-directories and sub-files
C: Set the root path to the directory where the cursor is located
u: Set the parent directory to the root path
U : Set the parent directory to follow the path, but keep the original directory open
r: Refresh the directory where the cursor is located
R: Refresh the current root path
I: Show or not show hidden files
f: Open and close the file filter
q: Close NERDTree
A: Display NERDTree in full screen, or close full screen The
above are some basic usages, only a few are commonly used.

NERDTree
NERDTree

adds some configurations.
In the process of using NERDTree, there are some inconvenient places that open files do not share NERDTree, so you need to install a shared plug-in vim-nerdtree-tabs, which makes you feel that you are just opening one. NERDTree

"Close NERDTree shortcut
map <leader>t :NERDTreeToggle<CR>
" Display line number
let NERDTreeShowLineNumbers=1
let NERDTreeAutoCenter=1
"whether to show hidden files
let NERDTreeShowHidden=1
" set the width
let NERDTreeWinSize=31
" when the terminal starts vim, share NERDTree
let g:nerdtree_tabs_open_on_console_startup=1
" ignore the display of the file
let NERDTreeIgnore=[' \.pyc','\~$','\.swp']
" Show bookmark list
let NERDTreeShowBookmarks=1
Show git information in NERDTree During
development , we want git information to be displayed directly in NERDTree, just like Eclipse , the modified files and the added files are marked accordingly. At this time, the plugin to be installed is the nerdtree-git-plugin

configuration information is as follows

let g:NERDTreeIndicatorMapCustom = {
\ "Modified" : "",
\ "Staged" : " ",
\ "Untracked" : "",
\ "Renamed" : "",
\ "Unmerged" : "═",
\ "Deleted" : "",
\ "Dirty" : "",
\ "Clean" : "︎",
\ "Unknown" : "?"
\ }
The following animation shows the effect of this plugin:

nerdtree-git -plugin
nerdtree-git-plugin

The original release time is: 2016-06-03

This article is from Yunqi community partner "Linux China"


using the Yunqi community APP, comfortable~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326351841&siteId=291194637