From 312ce93bb47cbadd4e0fe0d667770fada7f004df Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 29 Jun 2008 13:31:46 +1200 Subject: [PATCH] make the t/T mappings work for bookmarks when you hit t/T on a bookmark a new tab is opened and, if the bookmark is a dir, a nerd tree is opened for that dir. If the bookmark is a file then just open the file --- plugin/NERD_tree.vim | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fc1513b..5cdda85 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -2749,8 +2749,8 @@ function! s:BindMappings() exec "nnoremap ". g:NERDTreeMapJumpLastChild ." :call JumpToLastChild()" exec "nnoremap ". g:NERDTreeMapJumpRoot ." :call JumpToRoot()" - exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call OpenNodeNewTab(0)" - exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call OpenNodeNewTab(1)" + exec "nnoremap ". g:NERDTreeMapOpenInTab ." :call OpenInNewTab(0)" + exec "nnoremap ". g:NERDTreeMapOpenInTabSilent ." :call OpenInNewTab(1)" exec "nnoremap ". g:NERDTreeMapOpenExpl ." :call OpenExplorer()" @@ -3159,27 +3159,35 @@ function! s:OpenExplorer() endif endfunction -" FUNCTION: s:OpenNodeNewTab(stayCurrentTab) {{{2 -" Opens the currently selected file from the explorer in a -" new tab -" +" FUNCTION: s:OpenInNewTab(stayCurrentTab) {{{2 +" Opens the selected node or bookmark in a new tab " Args: " stayCurrentTab: if 1 then vim will stay in the current tab, if 0 then vim " will go to the tab where the new file is opened -function! s:OpenNodeNewTab(stayCurrentTab) +function! s:OpenInNewTab(stayCurrentTab) + let currentTab = tabpagenr() + let treenode = s:GetSelectedNode() if treenode != {} - let curTabNr = tabpagenr() exec "tabedit " . treenode.path.StrForEditCmd() if a:stayCurrentTab - exec "tabnext " . curTabNr + exec "tabnext " . currentTab endif else - call s:Echo("select a node first") + let bookmark = s:GetSelectedBookmark() + if bookmark != {} + if bookmark.path.isDirectory + exec "tabnew +NERDTreeFromBookmark\\ " . bookmark.name + else + exec "tabedit " . bookmark.path.StrForEditCmd() + endif + if a:stayCurrentTab + exec "tabnext " . currentTab + endif + endif endif endfunction - " FUNCTION: s:OpenNodeRecursively() {{{2 function! s:OpenNodeRecursively() let treenode = s:GetSelectedNode()