Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NerdTree copy command in Windows 7

Tags:

vim

nerdtree

I don't see the menu option for Copy command. Here is the menu that I see on my Windows 7 machine:

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.

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?

like image 884
Harish Shetty Avatar asked Oct 08 '22 09:10

Harish Shetty


2 Answers

I got it working by installing Gow

choco install -y gow

Then adding this line to vim

let g:NERDTreeCopyCmd= 'cp -r'

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

PS: The choco command comes from https://chocolatey.org/

like image 162
Emad Avatar answered Oct 12 '22 23:10

Emad


The root cause for the issue is discussed in detail(rather colorfully) in this blog post.(ht romainl). I managed to find a solution by using the cp.exe shipped with msygit.

Ensure cp.exe is in your path

The cp.exe file can be found in <GIT_HOME>\bin directory. My path didn't not contain the <GIT_HOME>\bin directory. So I copied cp.exe and msys-1.0.dll to a directory in my path.

Set the g:NERDTreeCopyCmd variable

Add the line below to the end of the _vimrc file

let g:NERDTreeCopyCmd= 'cp -r '

Fix the implementation of s:Path.copy function.

Replace the lines 2297-2299 of ~/vimfiles/bundle/nerdtree/plugin/NERD_tree.vim (assuming you used pathogen for managing vim plugins)

  • Replace the lines 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
    
like image 42
Harish Shetty Avatar answered Oct 12 '22 22:10

Harish Shetty