refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / vim-nerdtree / README.md
1 ---
2 title: vim-nerdtree
3 homepage: https://github.com/preservim/nerdtree
4 tagline: |
5   NERDTree: A tree explorer plugin for vim.
6 ---
7
8 To update (replacing the current version) run `webi vim-nerdtree`.
9
10 ## Cheat Sheet
11
12 ![](https://raw.githubusercontent.com/preservim/nerdtree/master/screenshot.png)
13
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.
17
18 This installer also includes a few reasonable defaults from the project's
19 README:
20
21 | Key                          | Action                                                               |
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                 |
38
39 (if you've installed [`vim-leader`](../vim-leader) then `<Leader>` is Space)
40
41 ### How to install and configure manually
42
43 Place NerdTree into your `~/.vim/pack/plugins/start`:
44
45 ```bash
46 mkdir -p ~/.vim/pack/plugins/start/
47 git clone --depth=1 https://github.com/preservim/nerdtree.git ~/.vim/pack/plugins/start/nerdtree
48 ```
49
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>.
52
53 That will look something like this:
54
55 `~/.vim/plugins/nerdtree.vim`:
56
57 ```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>
63
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>
67
68 " show hidden files
69 let NERDTreeShowHidden=1
70
71 " keep ignoring .git, node_modules, vendor, and dist
72 let NERDTreeIgnore=["\.git", "node_modules", "vendor", "dist"]
73
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
77
78 " Exit Vim if NERDTree is the only window left.
79 autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() |
80     \ quit | endif
81
82 ```
83
84 You'll then need to update `~/.vimrc` to source that plugin:
85
86 ```vim
87 " nerdtree: reasonable defaults from webinstall.dev/vim-nerdtree
88 source ~/.vim/plugins/nerdtree.vim
89 ```