From 76d2ecbb178ccfe4a4079ecf738f0a63714655d0 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Sun, 31 Aug 2008 20:55:24 +1200 Subject: [PATCH] add keymap to delete bookmarks --- doc/NERD_tree.txt | 10 ++++++++++ plugin/NERD_tree.vim | 29 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/doc/NERD_tree.txt b/doc/NERD_tree.txt index e21aaef..b09f3a5 100644 --- 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| @@ -342,6 +344,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 diff --git a/plugin/NERD_tree.vim b/plugin/NERD_tree.vim index fcabf08..5974ba9 100644 --- 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 ". g:NERDTreeMapOpenExpl ." :call OpenExplorer()" + exec "nnoremap ". g:NERDTreeMapDeleteBookmark ." :call DeleteBookmark()" + command! -buffer -nargs=1 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('') @@ -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