简体   繁体   English

Windows 7中的NerdTree复制命令

[英]NerdTree copy command in Windows 7

I don't see the menu option for Copy command.我没有看到Copy命令的菜单选项。 Here is the menu that I see on my Windows 7 machine:这是我在 Windows 7 机器上看到的菜单:

NERDTree Menu. Use j/k/enter and the shortcuts indicated
==========================================================
> (a)dd a childnode
  (m)ove the curent node
  (d)elete the curent node

According to the plugin documentation , the Copy command is not supported on all platforms.根据插件文档,并非所有平台都支持Copy命令。

A textual filesystem menu is provided which allows you to create/delete/move file 
and directory nodes as well as copy (for supported OSs)

Has anybody managed to get this to work in Windows?有没有人设法让它在 Windows 中工作?

The root cause for the issue is discussed in detail(rather colorfully) in this blog post .(ht romainl ). 在这篇博客文章中详细讨论了这个问题的根本原因(相当丰富多彩)。(ht romainl )。 I managed to find a solution by using the cp.exe shipped with msygit . 我设法找到使用的解决方案cp.exemsygit

Ensure cp.exe is in your path 确保cp.exe在您的路径中

The cp.exe file can be found in <GIT_HOME>\\bin directory. 可以在<GIT_HOME>\\bin目录中找到cp.exe文件。 My path didn't not contain the ``\\bin directory. So I copied 我的路径没有包含``\\ bin directory. So I copied directory. So I copied cp.exe and msys-1.0.dll` to a directory in my path. directory. So I copied cp.exe and msys-1.0.dll` directory. So I copied到我路径中的目录中。

Set the g:NERDTreeCopyCmd variable 设置g:NERDTreeCopyCmd变量

Add the line below to the end of the _vimrc file 将下面的行添加到_vimrc文件的末尾

let g:NERDTreeCopyCmd= 'cp -r '

Fix the implementation of s:Path.copy function. 修复s:Path.copy函数的实现。

Replace the lines 2297-2299 of ~/vimfiles/bundle/nerdtree/plugin/NERD_tree.vim (assuming you used pathogen for managing vim plugins) 替换~/vimfiles/bundle/nerdtree/plugin/NERD_tree.vim (假设您使用病原体来管理vim插件)

  • Replace the lines 2297-2299 更换线2297-2299

     let dest = s:Path.WinToUnixPath(a:dest) let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), s:escape_chars) . " " . escape(dest, s:escape_chars) 
  • With the lines below 有了以下几行

     let dest = a:dest let cmd = 0 if s:running_windows let cmd = g:NERDTreeCopyCmd . '"' . self.str() . '" "' . dest . '"' else let cmd = g:NERDTreeCopyCmd . " " . escape(self.str(), s:escape_chars) . " " . escape(dest, s:escape_chars) endif 

I got it working by installing Gow 我通过安装Gow来实现它

choco install -y gow

Then adding this line to vim 然后将此行添加到vim

let g:NERDTreeCopyCmd= 'cp -r'

Thanks: https://github.com/scrooloose/nerdtree/issues/152 谢谢: https//github.com/scrooloose/nerdtree/issues/152

PS: The choco command comes from https://chocolatey.org/ PS:choco命令来自https://chocolatey.org/

What I did was I added the following to my vimrc我所做的是将以下内容添加到我的 vimrc

if (has('win32'))
    " let g:NERDTreeCopyCmd= 'copy '
    let g:NERDTreeCopyCmd= 'Copy-Item -Recurse '
endif

First one works, but I set it to the second, I think you need that for copying directories properly..第一个有效,但我将其设置为第二个,我认为您需要它才能正确复制目录。

I just tried delete, and that also fails.我刚刚尝试删除,但也失败了。 Guess we need a similar workaround.猜猜我们需要一个类似的解决方法。

EDIT: Sorry, you will have to set your shell to run PowerShell for the second command to work!编辑:抱歉,您必须将 shell 设置为运行 PowerShell 才能使第二条命令生效!

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

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