commit 12dea6ccb2381a2b6b8ae0bf17b4078699bbfec3
parent 70dc34cb6979546e26cc6f874fe087457522165b
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date: Thu, 13 Jun 2019 09:17:19 -0400
Add a "copy path to clipboard" menu option (#1002)
* Add menu item to copy the node's path to the clipboard.
It works on Mac. Check Windows later.
* Handle case where clipboard is not a compiled feature of Vim.
* Change menu text if clipboard is unavailable.
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/nerdtree_plugin/fs_menu.vim b/nerdtree_plugin/fs_menu.vim
@@ -37,6 +37,7 @@ endif
if g:NERDTreePath.CopyingSupported()
call NERDTreeAddMenuItem({'text': '(c)opy the current node', 'shortcut': 'c', 'callback': 'NERDTreeCopyNode'})
endif
+call NERDTreeAddMenuItem({'text': (has("clipboard")?'copy (p)ath to clipboard':'print (p)ath to screen'), 'shortcut': 'p', 'callback': 'NERDTreeCopyPath'})
if has("unix") || has("osx")
call NERDTreeAddMenuItem({'text': '(l)ist the current node', 'shortcut': 'l', 'callback': 'NERDTreeListNode'})
@@ -364,6 +365,17 @@ function! NERDTreeCopyNode()
redraw!
endfunction
+" FUNCTION: NERDTreeCopyPath() {{{1
+function! NERDTreeCopyPath()
+ let l:nodePath = g:NERDTreeFileNode.GetSelected().path.str()
+ if has("clipboard")
+ let @* = l:nodePath
+ call nerdtree#echo("The path [" . l:nodePath . "] was copied to your clipboard.")
+ else
+ call nerdtree#echo("The full path is: " . l:nodePath)
+ endif
+endfunction
+
" FUNCTION: NERDTreeQuickLook() {{{1
function! NERDTreeQuickLook()
let treenode = g:NERDTreeFileNode.GetSelected()