From 95acf7dd253686bae54d1c2ad73453c174fb7e11 Mon Sep 17 00:00:00 2001 From: marty Date: Sun, 9 Aug 2009 21:29:28 +1200 Subject: [PATCH] add A mapping to maximize/restore tree window size this commit is a modified patch from Guillaume Duranceau --- doc/NERD_tree.txt | 12 ++++++++++++ plugin/NERD_tree.vim | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index a54de3a..77d5cbd 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -239,6 +239,7 @@ F.......Toggle whether files are displayed.......................|NERDTree-F| B.......Toggle whether the bookmark table is displayed...........|NERDTree-B| q.......Close the NERDTree window................................|NERDTree-q| +A.......Zoom (maximize/minimize) the NERDTree window.............|NERDTree-A| ?.......Toggle the display of the quick help.....................|NERDTree-?| ------------------------------------------------------------------------------ @@ -546,6 +547,14 @@ Applies to: no restrictions. Closes the NERDtree window. +------------------------------------------------------------------------------ + *NERDTree-A* +Default key: A +Map option: NERDTreeMapToggleZoom +Applies to: no restrictions. + +Maximize (zoom) and minimize the NERDtree window. + ------------------------------------------------------------------------------ *NERDTree-?* Default key: ? @@ -1002,6 +1011,8 @@ Next release: NERDTreeQuitOnOpen didnt play nicely, thanks to Curtis Harvey. - fix a bug where the script ignored directories whose name ended in a dot, thanks to Aggelos Orfanakos for the patch. + - added a mapping to maximize/restore the size of nerd tree window, thanks + to Guillaume Duranceau for the patch. See :help NERDTree-z for details. 3.1.1 - fix a bug where a non-listed no-name buffer was getting created every @@ -1094,6 +1105,7 @@ just downloaded pr0n instead. Alf Mikula Lucas S. Buchala Curtis Harvey + Guillaume Duranceau ============================================================================== 8. License *NERDTreeLicense* diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index d653f67..cb24e06 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -128,6 +128,7 @@ call s:initVariable("g:NERDTreeMapToggleBookmarks", "B") call s:initVariable("g:NERDTreeMapToggleFiles", "F") call s:initVariable("g:NERDTreeMapToggleFilters", "f") call s:initVariable("g:NERDTreeMapToggleHidden", "I") +call s:initVariable("g:NERDTreeMapToggleZoom", "A") call s:initVariable("g:NERDTreeMapUpdir", "u") call s:initVariable("g:NERDTreeMapUpdirKeepOpen", "U") @@ -2499,6 +2500,8 @@ function! s:dumpHelp() let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Other mappings~\n" let @h=@h."\" ". g:NERDTreeMapQuit .": Close the NERDTree window\n" + let @h=@h."\" ". g:NERDTreeMapToggleZoom .": Zoom (maximize-minimize)\n" + let @h=@h."\" the NERDTree window\n" let @h=@h."\" ". g:NERDTreeMapHelp .": toggle help\n" let @h=@h."\"\n\" ----------------------------\n" let @h=@h."\" Bookmark commands~\n" @@ -3095,6 +3098,7 @@ function! s:bindMappings() exec "nnoremap ". g:NERDTreeMapRefresh ." :call refreshCurrent()" exec "nnoremap ". g:NERDTreeMapHelp ." :call displayHelp()" + exec "nnoremap ". g:NERDTreeMapToggleZoom ." :call toggleZoom()" exec "nnoremap ". g:NERDTreeMapToggleHidden ." :call toggleShowHidden()" exec "nnoremap ". g:NERDTreeMapToggleFilters ." :call toggleIgnoreFilter()" exec "nnoremap ". g:NERDTreeMapToggleFiles ." :call toggleShowFiles()" @@ -3767,6 +3771,19 @@ function! s:toggleShowHidden() call s:centerView() endfunction +" FUNCTION: s:toggleZoom() {{2 +" zoom (maximize/minimize) the NERDTree window +function! s:toggleZoom() + if exists("b:NERDTreeZoomed") && b:NERDTreeZoomed + let size = exists("b:NERDTreeOldWindowSize") ? b:NERDTreeOldWindowSize : g:NERDTreeWinSize + exec "silent vertical resize ". size + let b:NERDTreeZoomed = 0 + else + exec "vertical resize" + let b:NERDTreeZoomed = 1 + endif +endfunction + "FUNCTION: s:upDir(keepState) {{{2 "moves the tree up a level "