3 homepage: https://github.com/preservim/nerdtree
5 NERDTree: A tree explorer plugin for vim.
8 To update (replacing the current version) run `webi vim-nerdtree`.
12 ![](https://raw.githubusercontent.com/preservim/nerdtree/master/screenshot.png)
14 > The NERDTree is a file system explorer for the Vim editor. Using this plugin,
15 > users can visually browse complex directory hierarchies, quickly open files
16 > for reading or editing, and perform basic file system operations.
18 This installer also includes a few reasonable defaults from the project's
22 | ---------------------------- | -------------------------------------------------------------------- |
23 | **Global Key Bindings** | |
24 | `<Leader>n` | Move cursor to NERDTree |
25 | `<ctrl>+t`<br>or `<Leader>`t | Toggle NERDTree window on/off |
26 | `<ctrl>+f`<br>or `<Leader>`f | Move to current file in NERDTree |
27 | **NERDTree Window Bindings** | |
28 | `o` | Open a directory to reveal children |
29 | `x` | Close directory and go to parent |
30 | `shift+o` | Open directory and all children dirs, recursively |
31 | `shift+x` | Close all child directories, recursively |
32 | `p` | Go to **p**arent directory |
33 | `gt` | Go to next Tab (`gT` for previous, naturally) |
34 | `/` | Search matches of visible files <br>(use `shift+o` first to see all) |
35 | **Normal Vim Stuff** | |
36 | `ctrl+w`, w | Rotate between open windows |
37 | `:e **/api.js<tab>` | Open and edit file matching api.js, in any subfolder |
39 (if you've installed [`vim-leader`](../vim-leader) then `<Leader>` is Space)
41 ### How to install and configure manually
43 Place NerdTree into your `~/.vim/pack/plugins/start`:
46 mkdir -p ~/.vim/pack/plugins/start/
47 git clone --depth=1 https://github.com/preservim/nerdtree.git ~/.vim/pack/plugins/start/nerdtree
50 Create the file `~/.vim/plugins/nerdtree.vim`. Add the same contents as
51 <https://github.com/webinstall/webi-installers/blob/master/vim-nerdtree/nerdtree.vim>.
53 That will look something like this:
55 `~/.vim/plugins/nerdtree.vim`:
58 " default mappings for nerdtree
59 nnoremap <leader>n :NERDTreeFocus<CR>
60 nnoremap <C-n> :NERDTree<CR>
61 nnoremap <C-t> :NERDTreeToggle<CR>
62 nnoremap <C-f> :NERDTreeFind<CR>
64 " also map with Leader, since ctrl is hard to reach on Mac
65 nnoremap <leader>t :NERDTreeToggle<CR>
66 nnoremap <leader>f :NERDTreeFind<CR>
69 let NERDTreeShowHidden=1
71 " keep ignoring .git, node_modules, vendor, and dist
72 let NERDTreeIgnore=["\.git", "node_modules", "vendor", "dist"]
74 " Start NERDTree when Vim is started without file arguments.
75 autocmd StdinReadPre * let s:std_in=1
76 autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
78 " Exit Vim if NERDTree is the only window left.
79 autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
84 You'll then need to update `~/.vimrc` to source that plugin:
87 " nerdtree: reasonable defaults from webinstall.dev/vim-nerdtree
88 source ~/.vim/plugins/nerdtree.vim