From dcccd0e532c44196195e352ae43745f47c8615d4 Mon Sep 17 00:00:00 2001 From: Min-Young Wu Date: Thu, 15 Dec 2011 15:14:31 -0800 Subject: [PATCH] Defaulting bookmark name to file/dir name Note that for directories, there is a trailing slash --- doc/NERD_tree.txt | 2 ++ plugin/NERD_tree.vim | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index cc5796a..3fa91f2 100644 --- a/doc/NERD_tree.txt +++ b/doc/NERD_tree.txt @@ -155,6 +155,8 @@ Note that the following commands are only available in the NERD tree buffer. :Bookmark Bookmark the current node as . If there is already a bookmark, it is overwritten. must not contain spaces. + If is not provided, it defaults to the file or directory name. + For directories, a trailing slash is present. :BookmarkToRoot Make the directory corresponding to the new root. If a treenode diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index 065ecf3..fbaee5e 100644 --- a/plugin/NERD_tree.vim +++ b/plugin/NERD_tree.vim @@ -3546,7 +3546,7 @@ function! s:bindMappings() "bind all the user custom maps call s:KeyMap.BindAll() - command! -buffer -nargs=1 Bookmark :call bookmarkNode('') + command! -buffer -nargs=? Bookmark :call bookmarkNode('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 RevealBookmark :call revealBookmark('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call openBookmark('') command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call clearBookmarks('') @@ -3558,11 +3558,15 @@ endfunction " FUNCTION: s:bookmarkNode(name) {{{2 " Associate the current node with the given name -function! s:bookmarkNode(name) +function! s:bookmarkNode(...) let currentNode = s:TreeFileNode.GetSelected() if currentNode != {} + let name = a:1 + if empty(name) + let name = currentNode.path.getLastPathComponent(1) + endif try - call currentNode.bookmark(a:name) + call currentNode.bookmark(name) call s:renderView() catch /^NERDTree.IllegalBookmarkNameError/ call s:echo("bookmark names must not contain spaces")