From 2e0b101d571a170c9919f180eae20100bcd6b62e Mon Sep 17 00:00:00 2001 From: Phil Runninger Date: Wed, 20 Feb 2019 23:57:51 -0500 Subject: [PATCH] Add an :EditBookmarks command to edit the bookmarks file (#954) * Add a new NERDTree buffer command to edit the bookmarks file. * Update the mini-help panel with missing bookmark commands. * Update the help file with the new :EditBookmarks command. --- doc/NERDTree.txt | 9 +++++++-- lib/nerdtree/bookmark.vim | 7 +++++++ lib/nerdtree/creator.vim | 1 + lib/nerdtree/ui.vim | 3 +++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/NERDTree.txt b/doc/NERDTree.txt index 5b2ef68..907ad4a 100644 --- a/doc/NERDTree.txt +++ b/doc/NERDTree.txt @@ -206,6 +206,10 @@ Note: The following commands are only available within the NERDTree buffer. :ClearAllBookmarks Remove all bookmarks. +:EditBookmarks + Opens the bookmarks file for manual editing, e.g. for removing invalid + bookmarks. + :ReadBookmarks Re-read the bookmarks in the |NERDTreeBookmarksFile|. @@ -218,13 +222,14 @@ If invalid bookmarks are detected, the script will issue an error message and the invalid bookmarks will become unavailable for use. These bookmarks will still be stored in the bookmarks file (see -|NERDTreeBookmarksFile|), down the bottom. There will always be a blank line +|NERDTreeBookmarksFile|), down at the bottom. There will always be a blank line after the valid bookmarks but before the invalid ones. Each line in the bookmarks file represents one bookmark. The proper format is: -After you have corrected any invalid bookmarks, either restart vim, or go +You can use the :EditBookmarks command to open the bookmarks file for editing. +After you have corrected any invalid bookmarks, either restart vim, or run :ReadBookmarks from the NERD tree window. ------------------------------------------------------------------------------ diff --git a/lib/nerdtree/bookmark.vim b/lib/nerdtree/bookmark.vim index 2e0aab0..c256aaf 100644 --- a/lib/nerdtree/bookmark.vim +++ b/lib/nerdtree/bookmark.vim @@ -156,6 +156,13 @@ function! s:Bookmark.delete() call s:Bookmark.Write() endfunction +" FUNCTION: s:Edit() {{{1 +" opens the NERDTreeBookmarks file for manual editing +function! s:Bookmark.Edit() + execute "wincmd w" + execute "edit ".g:NERDTreeBookmarksFile +endfunction + " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1 " Returns the tree node object associated with this Bookmark. " Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. diff --git a/lib/nerdtree/creator.vim b/lib/nerdtree/creator.vim index 1afd056..980cf80 100644 --- a/lib/nerdtree/creator.vim +++ b/lib/nerdtree/creator.vim @@ -26,6 +26,7 @@ function! s:Creator._bindMappings() command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() call b:NERDTree.render() command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) call b:NERDTree.render() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() + command! -buffer -nargs=0 EditBookmarks call g:NERDTreeBookmark.Edit() endfunction " FUNCTION: s:Creator._broadcastInitEvent() {{{1 diff --git a/lib/nerdtree/ui.vim b/lib/nerdtree/ui.vim index 5e3fcf1..c289f90 100644 --- a/lib/nerdtree/ui.vim +++ b/lib/nerdtree/ui.vim @@ -119,6 +119,9 @@ function! s:UI._dumpHelp() let help .= "\" :OpenBookmark \n" let help .= "\" :ClearBookmarks []\n" let help .= "\" :ClearAllBookmarks\n" + let help .= "\" :ReadBookmarks\n" + let help .= "\" :WriteBookmarks\n" + let help .= "\" :EditBookmarks\n" silent! put =help elseif !self.isMinimal() let help ="\" Press ". g:NERDTreeMapHelp ." for help\n"