nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 312ce93bb47cbadd4e0fe0d667770fada7f004df
parent 06776557cf99d470e5ccdb06ebd93f8ba30af708
Author: Martin Grenfell <martin_grenfell@msn.com>
Date:   Sun, 29 Jun 2008 13:31:46 +1200

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

Diffstat:
Mplugin/NERD_tree.vim | 30+++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -2749,8 +2749,8 @@ function! s:BindMappings()
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpLastChild ." :call <SID>JumpToLastChild()<cr>"
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapJumpRoot ." :call <SID>JumpToRoot()<cr>"
 
-    exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>OpenNodeNewTab(0)<cr>"
-    exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenNodeNewTab(1)<cr>"
+    exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTab ." :call <SID>OpenInNewTab(0)<cr>"
+    exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenInTabSilent ." :call <SID>OpenInNewTab(1)<cr>"
 
     exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
 
@@ -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()