Failed to copy files from Vim netrw on Mac OS X.

To copy a file to Vim using netrw, follow these steps:

  • Select destination directory (using mt )
  • Select the file to copy (using mf )
  • Continue copying (using mc )

Commands for use in netrw:

mt run while the cursor is at the top of the destination directory.
mf run while the cursor is on top of the file to be copied

mc run while the cursor is over the destination folder ("marked target")

If I do this in a project example, Vim will display something like:

 Copy foo.md to : bar.md 

Offering to do this to do what I want, but confirming this, I get the following error:

 1 **error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work! 

I read on the internet that netrw is considered pretty wrong, and there seems to be no much documentation or notes on how to solve this problem.

I should be clear and state that I am not interested in using NERDTree.

+4
source share
2 answers

I think I understood the original problem:

I had two folders foo and bar (one file in each), and I marked foo as the destination directory, and then pressed ENTER in the bar folder (just to look at the files inside it), and then press ENTER on foo (to also view files inside it). At this point, I moved the cursor up to the bar folder and pressed mf in the file I wanted to copy. But as for netrw, I still "focused" on the foo folder.

The solution was:

At this point (assuming I took the above steps until you click mf ): I have to press ENTER in the bar folder (hiding the listed files), and then press ENTER again in the bar folder (now re-show the contents / listed files) and finally , press mf in the file inside bar that I want to copy. NOW , for netrw, I put the file in the correct directory and the mc command will succeed.

The error I made suggested that moving the cursor inside the folder was enough for mf work. I forgot to understand that I need to “focus” in the correct folder for the mf command to work.

+1
source

read more at :help netrw-c to learn more about the current directory and directory mismatch.

you either want to press c before the process, or just let g:netrw_keepdir=0 in .vimrc

+5
source

All Articles