Skip to content

Commit 95acf7d

Browse files
author
marty
committed
add A mapping to maximize/restore tree window size
this commit is a modified patch from Guillaume Duranceau
1 parent c3a2f88 commit 95acf7d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

doc/NERD_tree.txt

+12
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ F.......Toggle whether files are displayed.......................|NERDTree-F|
239239
B.......Toggle whether the bookmark table is displayed...........|NERDTree-B|
240240

241241
q.......Close the NERDTree window................................|NERDTree-q|
242+
A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A|
242243
?.......Toggle the display of the quick help.....................|NERDTree-?|
243244

244245
------------------------------------------------------------------------------
@@ -546,6 +547,14 @@ Applies to: no restrictions.
546547

547548
Closes the NERDtree window.
548549

550+
------------------------------------------------------------------------------
551+
*NERDTree-A*
552+
Default key: A
553+
Map option: NERDTreeMapToggleZoom
554+
Applies to: no restrictions.
555+
556+
Maximize (zoom) and minimize the NERDtree window.
557+
549558
------------------------------------------------------------------------------
550559
*NERDTree-?*
551560
Default key: ?
@@ -1002,6 +1011,8 @@ Next release:
10021011
NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey.
10031012
- fix a bug where the script ignored directories whose name ended in a dot,
10041013
thanks to Aggelos Orfanakos for the patch.
1014+
- added a mapping to maximize/restore the size of nerd tree window, thanks
1015+
to Guillaume Duranceau for the patch. See :help NERDTree-z for details.
10051016

10061017
3.1.1
10071018
- fix a bug where a non-listed no-name buffer was getting created every
@@ -1094,6 +1105,7 @@ just downloaded pr0n instead.
10941105
Alf Mikula
10951106
Lucas S. Buchala
10961107
Curtis Harvey
1108+
Guillaume Duranceau
10971109

10981110
==============================================================================
10991111
8. License *NERDTreeLicense*

plugin/NERD_tree.vim

+17
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ call s:initVariable("g:NERDTreeMapToggleBookmarks", "B")
128128
call s:initVariable("g:NERDTreeMapToggleFiles", "F")
129129
call s:initVariable("g:NERDTreeMapToggleFilters", "f")
130130
call s:initVariable("g:NERDTreeMapToggleHidden", "I")
131+
call s:initVariable("g:NERDTreeMapToggleZoom", "A")
131132
call s:initVariable("g:NERDTreeMapUpdir", "u")
132133
call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U")
133134

@@ -2499,6 +2500,8 @@ function! s:dumpHelp()
24992500
let @h=@h."\"\n\" ----------------------------\n"
25002501
let @h=@h."\" Other mappings~\n"
25012502
let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n"
2503+
let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n"
2504+
let @h=@h."\" the NERDTree window\n"
25022505
let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n"
25032506
let @h=@h."\"\n\" ----------------------------\n"
25042507
let @h=@h."\" Bookmark commands~\n"
@@ -3095,6 +3098,7 @@ function! s:bindMappings()
30953098
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapRefresh ." :call <SID>refreshCurrent()<cr>"
30963099

30973100
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapHelp ." :call <SID>displayHelp()<cr>"
3101+
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleZoom ." :call <SID>toggleZoom()<cr>"
30983102
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleHidden ." :call <SID>toggleShowHidden()<cr>"
30993103
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFilters ." :call <SID>toggleIgnoreFilter()<cr>"
31003104
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapToggleFiles ." :call <SID>toggleShowFiles()<cr>"
@@ -3767,6 +3771,19 @@ function! s:toggleShowHidden()
37673771
call s:centerView()
37683772
endfunction
37693773

3774+
" FUNCTION: s:toggleZoom() {{2
3775+
" zoom (maximize/minimize) the NERDTree window
3776+
function! s:toggleZoom()
3777+
if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed
3778+
let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize
3779+
exec "silent vertical resize ". size
3780+
let b:NERDTreeZoomed = 0
3781+
else
3782+
exec "vertical resize"
3783+
let b:NERDTreeZoomed = 1
3784+
endif
3785+
endfunction
3786+
37703787
"FUNCTION: s:upDir(keepState) {{{2
37713788
"moves the tree up a level
37723789
"

0 commit comments

Comments
 (0)