简体   繁体   English

使用NERDtree Vim插件复制路径文件

[英]Copy path file with NERDtree Vim plugin

Is there some way to copy the path of a file in the Vim's NERDtree plugin? 有没有办法在Vim的NERDtree插件中复制文件的路径?

Better: is there some plugin to make the same operations the SideBarEnhancements plugin of Sublime Text does? 更好:是否有一些插件可以使Sublime Text的SideBarEnhancements插件进行相同的操作?

NERD_tree comes with its own extension system; NERD_tree有自己的扩展系统; just put the following fragment into ~/.vim/nerdtree_plugin/yank_mapping.vim : 只需将以下片段放入~/.vim/nerdtree_plugin/yank_mapping.vim

call NERDTreeAddKeyMap({
        \ 'key': 'yy',
        \ 'callback': 'NERDTreeYankCurrentNode',
        \ 'quickhelpText': 'put full path of current node into the default register' })

function! NERDTreeYankCurrentNode()
    let n = g:NERDTreeFileNode.GetSelected()
    if n != {}
        call setreg('"', n.path.str())
    endif
endfunction

Of course, you can adapt the default key ( yy ), and register ( " ; use + for the clipboard). 当然,您可以调整默认密钥( yy ),并注册( " ;使用+作为剪贴板)。

This is what I found for NERDTree with a quick google: CopyPath 这是我用NERDTree快速google发现的: CopyPath

However it sounds like you are trying to make vim into Sublime Text. 然而,听起来你正试图让vim成为Sublime Text。 Vim tends to have a very different philosophy on text editing than most text editors. 与大多数文本编辑器相比,Vim在文本编辑方面往往具有非常不同的理念。 In my personal opinion it is often better to work with vim than against it. 在我个人看来,与vim合作通常比使用vim更好。 Here is a nice post by Drew Neil of Vimcasts explaining the benefit to split explorers . 这是Vimcasts的Drew Neil发表的一篇精彩文章,解释了分裂探险家好处

Probably the more vim way of inserting a path is to use file completion. 可能更多vim插入路径的方法是使用文件完成。 When in insert mode you can trigger this completion by pressing <cx><cf> then go through the menu with <cp> and <cn> (previous and next respectively). 在插入模式下,您可以通过按<cx><cf>然后使用<cp><cn> (分别为上一个和下一个)浏览菜单来触发此完成。 If you want to insert the current buffers path you can paste it via the % register eg "%p or in insert/command-line mode press with <cr>% . 如果要插入当前缓冲区路径,可以通过%寄存器粘贴它,例如"%p或插入/命令行模式下按<cr>%

For more help see: 有关更多帮助请参阅:

:h ins_completion
:h i_CTRL-R
:h quote%
:h registers

I guess what you really need is a context menu like that sublime plugin? 我猜你真正需要的是像这个崇高的插件一样的上下文菜单?

That's built-in with NERDTree. 这是内置的NERDTree。

Just hit m on the node you highlighted and you'll see a new window pop under asking you what you want to do. 只需点击你突出显示的节点上的m ,就会看到一个新窗口,询问你想要做什么。 The basic functions are: Add, Delete, Move, Copy. 基本功能包括:添加,删除,移动,复制。

There is also a plugin to let you search(using grep), either for single file or whole directory highlighted. 还有一个插件可以让您搜索(使用grep),可以突出显示单个文件或整个目录。

NERDTree also provides API for your easily built any custom actions in that context window. NERDTree还为您在该上下文窗口中轻松构建的任何自定义操作提供API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM