nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit 2e0b101d571a170c9919f180eae20100bcd6b62e
parent f4d2b301b71ccb1b5a7742f63638828073424dc1
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Wed, 20 Feb 2019 23:57:51 -0500

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.

Diffstat:
Mdoc/NERDTree.txt | 9+++++++--
Mlib/nerdtree/bookmark.vim | 7+++++++
Mlib/nerdtree/creator.vim | 1+
Mlib/nerdtree/ui.vim | 3+++
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git 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:
 <bookmark name><space><full path to the bookmark location>
 
-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
@@ -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
@@ -26,6 +26,7 @@ function! s:Creator._bindMappings()
     command! -buffer -nargs=0 ClearAllBookmarks call g:NERDTreeBookmark.ClearAll() <bar> call b:NERDTree.render()
     command! -buffer -nargs=0 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> 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
@@ -119,6 +119,9 @@ function! s:UI._dumpHelp()
         let help .= "\" :OpenBookmark <name>\n"
         let help .= "\" :ClearBookmarks [<names>]\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"