Skip to content

Commit 5a69010

Browse files
author
Martin Grenfell
committed
latest nerd tree
1 parent c903f08 commit 5a69010

File tree

2 files changed

+296
-160
lines changed

2 files changed

+296
-160
lines changed

doc/NERD_tree.txt

Lines changed: 88 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CONTENTS *NERDTree-contents*
3131
3.Options.................................|NERDTreeOptions|
3232
3.1 Option summary....................|NERDTreeOptionSummary|
3333
3.2 Option details....................|NERDTreeOptionDetails|
34-
4.Public functions........................|NERDTreePublicFunctions|
34+
4.Hacking the NERD tree...................|NERDTreeHacking|
3535
5.TODO list...............................|NERDTreeTodo|
3636
6.The Author..............................|NERDTreeAuthor|
3737
7.Changelog...............................|NERDTreeChangelog|
@@ -65,7 +65,7 @@ The following features and functionality are provided by the NERD tree:
6565
* ...
6666
* Directories and files can be bookmarked.
6767
* Most NERD tree navigation can also be done with the mouse
68-
* Dynamic customisation of tree content
68+
* Filtering of tree content (can be toggled at runtime)
6969
* custom file filters to prevent e.g. vim backup files being displayed
7070
* optional displaying of hidden files (. files)
7171
* files can be "turned off" so that only directories are displayed
@@ -81,9 +81,13 @@ The following features and functionality are provided by the NERD tree:
8181
session, the directory nodes will be opened/closed as you left them
8282
* The script remembers the cursor position and window position in the NERD
8383
tree so you can toggle it off (or just close the tree window) and then
84-
reopen it (with NERDTreeToggle) the NERD tree window will appear EXACTLY
84+
reopen it (with NERDTreeToggle) the NERD tree window will appear exactly
8585
as you left it
86-
* You can have a separate NERD tree for each tab
86+
* You can have a separate NERD tree for each tab, share trees across tabs,
87+
or a mix of both.
88+
* By default the script overrides the default file browser (netw), so if
89+
you :edit a directory a (slighly modified) NERD tree will appear in the
90+
current window
8791

8892
==============================================================================
8993
2. Functionality provided *NERDTreeFunctionality*
@@ -109,7 +113,15 @@ The following features and functionality are provided by the NERD tree:
109113
again. If no NERD tree exists for this tab then this command acts the
110114
same as the |:NERDTree| command.
111115

112-
:NERDTreeClose
116+
:NERDTreeMirror *:NERDTreeMirror*
117+
Shares an existing NERD tree, from another tab, in the current tab.
118+
Changes made to one tree are reflected in both as they are actually the
119+
same buffer.
120+
121+
If only one other NERD tree exists, that tree is automatically mirrored. If
122+
more than one exists, the script will ask which tree to mirror.
123+
124+
:NERDTreeClose *:NERDTreeClose*
113125
Close the NERD tree in this tab.
114126

115127
------------------------------------------------------------------------------
@@ -190,16 +202,16 @@ o.......Open files, directories and bookmarks....................|NERDTree-o|
190202
go......Open selected file, but leave cursor in the NERDTree.....|NERDTree-go|
191203
t.......Open selected node/bookmark in a new tab.................|NERDTree-t|
192204
T.......Same as 't' but keep the focus on the current tab........|NERDTree-T|
193-
<tab>...Open selected file in a split window.....................|NERDTree-tab|
194-
g<tab>..Same as <tab>, but leave the cursor on the NERDTree......|NERDTree-gtab|
205+
i.......Open selected file in a split window.....................|NERDTree-i|
206+
gi......Same as i, but leave the cursor on the NERDTree..........|NERDTree-i|
195207
!.......Execute the current file.................................|NERDTree-!|
196208
O.......Recursively open the selected directory..................|NERDTree-O|
197209
x.......Close the current nodes parent...........................|NERDTree-x|
198210
X.......Recursively close all children of the current node.......|NERDTree-X|
199-
e.......Open a netrw for the current dir.........................|NERDTree-e|
211+
e.......Edit the current dif.....................................|NERDTree-e|
200212

201213
double-click.......same as the |NERDTree-o| map.
202-
middle-click.......same as |NERDTree-tab| for files, same as
214+
middle-click.......same as |NERDTree-i| for files, same as
203215
|NERDTree-e| for dirs.
204216

205217
D.......Delete the current bookmark .............................|NERDTree-D|
@@ -219,7 +231,7 @@ R.......Recursively refresh the current root.....................|NERDTree-R|
219231
m.......Display the filesystem menu..............................|NERDTree-m|
220232
cd......Change the CWD to the dir of the selected node...........|NERDTree-cd|
221233

222-
H.......Toggle whether hidden files displayed....................|NERDTree-H|
234+
I.......Toggle whether hidden files displayed....................|NERDTree-I|
223235
f.......Toggle whether the file filters are used.................|NERDTree-f|
224236
F.......Toggle whether files are displayed.......................|NERDTree-F|
225237
B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
@@ -278,24 +290,24 @@ Applies to: files and directories.
278290
The same as |NERDTree-t| except that the focus is kept in the current tab.
279291

280292
------------------------------------------------------------------------------
281-
*NERDTree-tab*
282-
Default key: <tab>
293+
*NERDTree-i*
294+
Default key: i
283295
Map option: NERDTreeMapOpenSplit
284296
Applies to: files.
285297

286298
Opens the selected file in a new split window and puts the cursor in the new
287299
window.
288300

289301
------------------------------------------------------------------------------
290-
*NERDTree-gtab*
291-
Default key: g<tab>
302+
*NERDTree-gi*
303+
Default key: gi
292304
Map option: None
293305
Applies to: files.
294306

295-
The same as |NERDTree-tab| except that the cursor is not moved.
307+
The same as |NERDTree-i| except that the cursor is not moved.
296308

297309
The key combo for this mapping is always "g" + NERDTreeMapOpenSplit (see
298-
|NERDTree-tab|).
310+
|NERDTree-i|).
299311

300312
------------------------------------------------------------------------------
301313
*NERDTree-!*
@@ -342,7 +354,9 @@ Default key: e
342354
Map option: NERDTreeMapOpenExpl
343355
Applies to: files and directories.
344356

345-
Opens a netrw on the selected directory, or the selected file's directory.
357+
|:edit|s the selected directory, or the selected file's directory. This could
358+
result in a NERD tree or a netrw being opened, depending on
359+
|'NERDTreeHijackNetrw'|.
346360

347361
------------------------------------------------------------------------------
348362
*NERDTree-D*
@@ -463,13 +477,12 @@ Applies to: files and directories.
463477
Display the filesystem menu. See |NERDTreeFilesysMenu| for details.
464478

465479
------------------------------------------------------------------------------
466-
*NERDTree-H*
467-
Default key: H
480+
*NERDTree-I*
481+
Default key: I
468482
Map option: NERDTreeMapToggleHidden
469483
Applies to: no restrictions.
470484

471-
Toggles whether hidden files are displayed. Hidden files are any
472-
file/directory that starts with a "."
485+
Toggles whether hidden files (i.e. "dot files") are displayed.
473486

474487
------------------------------------------------------------------------------
475488
*NERDTree-f*
@@ -580,6 +593,9 @@ NERD tree. These options should be set in your vimrc.
580593
|'NERDTreeHighlightCursorline'| Tell the NERD tree whether to highlight the
581594
current cursor line.
582595

596+
|'NERDTreeHijackNetrw'| Tell the NERD tree whether to replace the netrw
597+
autocommands for exploring local directories.
598+
583599
|'NERDTreeIgnore'| Tells the NERD tree which files to ignore.
584600

585601
|'NERDTreeBookmarksFile'| Where the bookmarks are stored.
@@ -705,6 +721,22 @@ Default: 1.
705721
If set to 1, the current cursor line in the NERD tree buffer will be
706722
highlighted. This is done using the |cursorline| option.
707723

724+
------------------------------------------------------------------------------
725+
*'NERDTreeHijackNetrw'*
726+
Values: 0 or 1.
727+
Default: 1.
728+
729+
If set to 1, doing a >
730+
:edit <some directory>
731+
<
732+
will open up a "secondary" NERD tree instead of a netrw in the target window.
733+
734+
Secondary NERD trees behaves slighly different from a regular trees in the
735+
following respects:
736+
1. 'o' will open the selected file in the same window as the tree,
737+
replacing it.
738+
2. you can have as many secondary tree as you want in the same tab.
739+
708740
------------------------------------------------------------------------------
709741
*'NERDTreeIgnore'*
710742
Values: a list of regular expressions.
@@ -760,7 +792,7 @@ Values: 0 or 1.
760792
Default: 0
761793

762794
If set to 1, the NERD tree window will close after opening a file with the
763-
|NERDTree-o| or |NERDTree-tab| mappings.
795+
|NERDTree-o| or |NERDTree-i| mappings.
764796

765797
------------------------------------------------------------------------------
766798
*'NERDTreeShowBookmarks'*
@@ -790,7 +822,7 @@ Values: 0 or 1.
790822
Default: 0.
791823

792824
This option tells vim whether to display hidden files by default. This option
793-
can be dynamically toggled, per tree, with the |NERDTree-H| mapping. Use one
825+
can be dynamically toggled, per tree, with the |NERDTree-I| mapping. Use one
794826
of the follow lines to set this option: >
795827
let NERDTreeShowHidden=0
796828
let NERDTreeShowHidden=1
@@ -842,15 +874,12 @@ Other examples: >
842874

843875
------------------------------------------------------------------------------
844876
*'NERDTreeWinPos'*
845-
Values: "left", "right", "top" or "bottom"
877+
Values: "left" or "right"
846878
Default: "left".
847879

848880
This option is used to determine where NERD tree window is placed on the
849881
screen.
850882

851-
"top" or "bottom", will cause a horizontal split to be created for the tree,
852-
while "left" and "right" will cause a vertical split.
853-
854883
This option is makes it possible to use two different explorer type
855884
plugins simultaneously. For example, you could have the taglist plugin on the
856885
left of the window and the NERD tree on the right.
@@ -863,8 +892,9 @@ Default: 31.
863892
This option is used to change the size of the NERD tree when it is loaded.
864893

865894
==============================================================================
866-
*NERDTreePublicFunctions*
867-
5. Public functions ~
895+
4. Hacking the NERD tree *NERDTreeHacking*
896+
897+
Public functions ~
868898

869899
The script provides 2 public functions for your hacking pleasure. Their
870900
signatures are: >
@@ -879,8 +909,26 @@ style OO. To see the functions that each class provides you can read look at
879909
the code.
880910

881911
Use the node objects to manipulate the structure of the tree. Use the path
882-
objects to access the data the tree represents and to make changes to the
883-
filesystem.
912+
objects to access the files/directories the tree nodes represent.
913+
914+
The NERD tree filetype ~
915+
916+
NERD tree buffers have a filetype of "nerdtree". You can use this to hack the
917+
NERD tree via autocommands (on |FileType|) or via an ftplugin.
918+
919+
For example, putting this code in ~/.vim/ftplugin/nerdtree.vim would override
920+
the o mapping, making it open the selected node in a new gvim instance. >
921+
922+
nnoremap <silent> <buffer> o :call <sid>openInNewVimInstance()<cr>
923+
function! s:openInNewVimInstance()
924+
let p = NERDTreeGetCurrentPath()
925+
if p != {}
926+
silent exec "!gvim " . p.strForOS(1) . "&"
927+
endif
928+
endfunction
929+
<
930+
This way you can add new mappings or :commands or override any existing
931+
mapping.
884932

885933
==============================================================================
886934
5. TODO list *NERDTreeTodo*
@@ -901,6 +949,15 @@ fridge for later ;)
901949
==============================================================================
902950
7. Changelog *NERDTreeChangelog*
903951

952+
3.0.0
953+
- hijack netrw so that doing an :edit <directory> will put a NERD tree in
954+
the window rather than a netrw browser. See :help 'NERDTreeHijackNetrw'
955+
- allow sharing of trees across tabs, see :help :NERDTreeMirror
956+
- remove "top" and "bottom" as valid settings for NERDTreeWinPos
957+
- change the '<tab>' mapping to 'i'
958+
- change the 'H' mapping to 'I'
959+
- lots of refactoring
960+
904961
2.14.3
905962
Thanks to tpope for the following:
906963
- use relative paths when doing edit commands if possible (useful if you

0 commit comments

Comments
 (0)