mirror of
https://github.com/preservim/nerdtree.git
synced 2025-11-08 19:33:50 -05:00
Defaulting bookmark name to file/dir name
Note that for directories, there is a trailing slash
This commit is contained in:
committed by
Martin Grenfell
parent
af833e3006
commit
dcccd0e532
@@ -155,6 +155,8 @@ Note that the following commands are only available in the NERD tree buffer.
|
|||||||
:Bookmark <name>
|
:Bookmark <name>
|
||||||
Bookmark the current node as <name>. If there is already a <name>
|
Bookmark the current node as <name>. If there is already a <name>
|
||||||
bookmark, it is overwritten. <name> must not contain spaces.
|
bookmark, it is overwritten. <name> must not contain spaces.
|
||||||
|
If <name> is not provided, it defaults to the file or directory name.
|
||||||
|
For directories, a trailing slash is present.
|
||||||
|
|
||||||
:BookmarkToRoot <bookmark>
|
:BookmarkToRoot <bookmark>
|
||||||
Make the directory corresponding to <bookmark> the new root. If a treenode
|
Make the directory corresponding to <bookmark> the new root. If a treenode
|
||||||
|
|||||||
@@ -3546,7 +3546,7 @@ function! s:bindMappings()
|
|||||||
"bind all the user custom maps
|
"bind all the user custom maps
|
||||||
call s:KeyMap.BindAll()
|
call s:KeyMap.BindAll()
|
||||||
|
|
||||||
command! -buffer -nargs=1 Bookmark :call <SID>bookmarkNode('<args>')
|
command! -buffer -nargs=? 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 RevealBookmark :call <SID>revealBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
|
command! -buffer -complete=customlist,s:completeBookmarks -nargs=1 OpenBookmark :call <SID>openBookmark('<args>')
|
||||||
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
|
command! -buffer -complete=customlist,s:completeBookmarks -nargs=* ClearBookmarks call <SID>clearBookmarks('<args>')
|
||||||
@@ -3558,11 +3558,15 @@ endfunction
|
|||||||
|
|
||||||
" FUNCTION: s:bookmarkNode(name) {{{2
|
" FUNCTION: s:bookmarkNode(name) {{{2
|
||||||
" Associate the current node with the given name
|
" Associate the current node with the given name
|
||||||
function! s:bookmarkNode(name)
|
function! s:bookmarkNode(...)
|
||||||
let currentNode = s:TreeFileNode.GetSelected()
|
let currentNode = s:TreeFileNode.GetSelected()
|
||||||
if currentNode != {}
|
if currentNode != {}
|
||||||
|
let name = a:1
|
||||||
|
if empty(name)
|
||||||
|
let name = currentNode.path.getLastPathComponent(1)
|
||||||
|
endif
|
||||||
try
|
try
|
||||||
call currentNode.bookmark(a:name)
|
call currentNode.bookmark(name)
|
||||||
call s:renderView()
|
call s:renderView()
|
||||||
catch /^NERDTree.IllegalBookmarkNameError/
|
catch /^NERDTree.IllegalBookmarkNameError/
|
||||||
call s:echo("bookmark names must not contain spaces")
|
call s:echo("bookmark names must not contain spaces")
|
||||||
|
|||||||
Reference in New Issue
Block a user