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.
This commit is contained in:
Phil Runninger 2019-02-20 23:57:51 -05:00 committed by GitHub
parent f4d2b301b7
commit 2e0b101d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 2 deletions

View File

@ -206,6 +206,10 @@ Note: The following commands are only available within the NERDTree buffer.
:ClearAllBookmarks :ClearAllBookmarks
Remove all bookmarks. Remove all bookmarks.
:EditBookmarks
Opens the bookmarks file for manual editing, e.g. for removing invalid
bookmarks.
:ReadBookmarks :ReadBookmarks
Re-read the bookmarks in the |NERDTreeBookmarksFile|. 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. the invalid bookmarks will become unavailable for use.
These bookmarks will still be stored in the bookmarks file (see 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. after the valid bookmarks but before the invalid ones.
Each line in the bookmarks file represents one bookmark. The proper format is: Each line in the bookmarks file represents one bookmark. The proper format is:
<bookmark name><space><full path to the bookmark location> <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. :ReadBookmarks from the NERD tree window.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -156,6 +156,13 @@ function! s:Bookmark.delete()
call s:Bookmark.Write() call s:Bookmark.Write()
endfunction 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 " FUNCTION: Bookmark.getNode(nerdtree, searchFromAbsoluteRoot) {{{1
" Returns the tree node object associated with this Bookmark. " Returns the tree node object associated with this Bookmark.
" Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found. " Throws "NERDTree.BookmarkedNodeNotFoundError" if the node is not found.

View File

@ -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 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 ReadBookmarks call g:NERDTreeBookmark.CacheBookmarks(0) <bar> call b:NERDTree.render()
command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write() command! -buffer -nargs=0 WriteBookmarks call g:NERDTreeBookmark.Write()
command! -buffer -nargs=0 EditBookmarks call g:NERDTreeBookmark.Edit()
endfunction endfunction
" FUNCTION: s:Creator._broadcastInitEvent() {{{1 " FUNCTION: s:Creator._broadcastInitEvent() {{{1

View File

@ -119,6 +119,9 @@ function! s:UI._dumpHelp()
let help .= "\" :OpenBookmark <name>\n" let help .= "\" :OpenBookmark <name>\n"
let help .= "\" :ClearBookmarks [<names>]\n" let help .= "\" :ClearBookmarks [<names>]\n"
let help .= "\" :ClearAllBookmarks\n" let help .= "\" :ClearAllBookmarks\n"
let help .= "\" :ReadBookmarks\n"
let help .= "\" :WriteBookmarks\n"
let help .= "\" :EditBookmarks\n"
silent! put =help silent! put =help
elseif !self.isMinimal() elseif !self.isMinimal()
let help ="\" Press ". g:NERDTreeMapHelp ." for help\n" let help ="\" Press ". g:NERDTreeMapHelp ." for help\n"