commit 76d2ecbb178ccfe4a4079ecf738f0a63714655d0
parent 73322e88d2db49048b05e2dc531d19f4bfd4f907
Author: Martin Grenfell <martin_grenfell@msn.com>
Date: Sun, 31 Aug 2008 20:55:24 +1200
add keymap to delete bookmarks
Diffstat:
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt
@@ -202,6 +202,8 @@ double-click.......same as the |NERDTree-o| map.
middle-click.......same as |NERDTree-tab| for files, same as
|NERDTree-e| for dirs.
+D.......Delete the current bookmark .............................|NERDTree-D|
+
P.......Jump to the root node....................................|NERDTree-P|
p.......Jump to current nodes parent.............................|NERDTree-p|
K.......Jump up inside directories at the current tree depth.....|NERDTree-K|
@@ -343,6 +345,14 @@ Applies to: files and directories.
Opens a netrw on the selected directory, or the selected file's directory.
------------------------------------------------------------------------------
+ *NERDTree-D*
+Default key: D
+Map option: NERDTreeMapDeleteBookmark
+Applies to: lines in the bookmarks table
+
+Deletes the currently selected bookmark.
+
+------------------------------------------------------------------------------
*NERDTree-P*
Default key: P
Map option: NERDTreeMapJumpRoot
diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim
@@ -95,6 +95,7 @@ call s:InitVariable("g:NERDTreeMapChangeRoot", "C")
call s:InitVariable("g:NERDTreeMapChdir", "cd")
call s:InitVariable("g:NERDTreeMapCloseChildren", "X")
call s:InitVariable("g:NERDTreeMapCloseDir", "x")
+call s:InitVariable("g:NERDTreeMapDeleteBookmark", "D")
call s:InitVariable("g:NERDTreeMapExecute", "!")
call s:InitVariable("g:NERDTreeMapFilesystemMenu", "m")
call s:InitVariable("g:NERDTreeMapHelp", "?")
@@ -1985,6 +1986,7 @@ function! s:DumpHelp()
let @h=@h."\" ". g:NERDTreeMapActivateNode .": open bookmark\n"
let @h=@h."\" ". g:NERDTreeMapOpenInTab.": open in new tab\n"
let @h=@h."\" ". g:NERDTreeMapOpenInTabSilent .": open in new tab silently\n"
+ let @h=@h."\" ". g:NERDTreeMapDeleteBookmark .": delete bookmark\n"
let @h=@h."\"\n\" ----------------------------\n"
let @h=@h."\" Tree navigation mappings~\n"
@@ -2918,6 +2920,8 @@ function! s:BindMappings()
exec "nnoremap <silent> <buffer> ". g:NERDTreeMapOpenExpl ." :call <SID>OpenExplorer()<cr>"
+ exec "nnoremap <silent> <buffer> ". g:NERDTreeMapDeleteBookmark ." :call <SID>DeleteBookmark()<cr>"
+
command! -buffer -nargs=1 Bookmark :call <SID>BookmarkNode('<args>')
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=1 RevealBookmark :call <SID>RevealBookmark('<args>')
command! -buffer -complete=customlist,s:CompleteBookmarks -nargs=1 OpenBookmark :call <SID>OpenBookmark('<args>')
@@ -3087,6 +3091,31 @@ function! s:CopyNode()
redraw
endfunction
+" FUNCTION: s:DeleteBookmark() {{{2
+" if the cursor is on a bookmark, prompt to delete
+function! s:DeleteBookmark()
+ let bookmark = s:GetSelectedBookmark()
+ if bookmark == {}
+ call s:Echo("Put the cursor on a bookmark")
+ return
+ endif
+
+ echo "Are you sure you wish to delete the bookmark:\n\"" . bookmark.name . "\" (yN):"
+
+ if nr2char(getchar()) == 'y'
+ try
+ call bookmark.Delete()
+ call s:RenderView()
+ redraw
+ catch /^NERDTree/
+ call s:EchoWarning("Could not remove bookmark")
+ endtry
+ else
+ call s:Echo("delete aborted" )
+ endif
+
+endfunction
+
" FUNCTION: s:DeleteNode() {{{2
" if the current node is a file, pops up a dialog giving the user the option
" to delete it