Copying files with Vim's netrw on Mac OS X is broken

223 views
Skip to first unread message

Mark McDonnell

unread,
Aug 7, 2015, 5:52:12 AM8/7/15
to vim_use
Hi, can anyone help me this issue with netrw?

To copy a file in Vim using netrw I have to following these steps:

1. Select the destination directory (using mt)
2. Select the file to be copied (using mf)
3. Proceed with copying (using mc)

The commands to use in netrw are:

- mt run while cursor is on top of the directory intended to be the destination
- mf run while cursor is on top of the file intended to be copied
- mc run while cursor is on top of the destination ("marked target") directory

If I do this on an example project, Vim will display something like:

Copy foo.md to : bar.md

Suggesting it's about to do what I want it to, but upon confirming this I get the following error:

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

I've read online that netrw is considered pretty buggy and so there doesn't appear to be much documentation or notes on how to resolve this issue.

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

Thanks

Charles Campbell

unread,
Aug 7, 2015, 11:50:02 AM8/7/15
to vim...@googlegroups.com
Mark McDonnell wrote:
> Hi, can anyone help me this issue with netrw?
>
> To copy a file in Vim using netrw I have to following these steps:
>
> 1. Select the destination directory (using mt)
> 2. Select the file to be copied (using mf)
> 3. Proceed with copying (using mc)
>
> The commands to use in netrw are:
>
> - mt run while cursor is on top of the directory intended to be the destination
> - mf run while cursor is on top of the file intended to be copied
> - mc run while cursor is on top of the destination ("marked target") directory
mc requires that the target directory and source file have been
selected. It doesn't require that it be done while the cursor is atop
the destination directory.
>
> If I do this on an example project, Vim will display something like:
>
> Copy foo.md to : bar.md
>
> Suggesting it's about to do what I want it to, but upon confirming this I get the following error:
>
> 1 **error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!
>
This means that system("cp 'your-selected-file'
'your-target-directory'") failed. Check your permissions and path.
What does :echo executable("cp") show?

Mark McDonnell

unread,
Aug 9, 2015, 4:30:14 PM8/9/15
to vim_use, Charles.E...@nasa.gov

Executing `:echo executable("cp")` returns a 1 for me

Oh and I think I've figured out the initial issue: if I had two folders foo and bar and I mark foo as the target and then press ENTER on the bar folder to have a look inside it, and then press ENTER on foo to look inside that; although I was moving my cursor inside the bar folder and pressing mf on a file inside the bar folder, as far as netrw is concerned I'm still "focused" on the foo folder.

The solution seemed to be: at this point I should press ENTER on bar (hiding the contents) and then again (showing the content) and finally press mf on the file inside bar I want to copy; now as far as netrw is concerned, I've marked the file inside the correct directory and the mc command will now succeed.

The mistake I had made was assuming just moving the cursor inside a folder was enough for mf to work. I neglected to realise that I had to be "focused" in the correct folder for the mf command to work.

One remaining question though is: how do you refresh the list of files? Looking at the help files I see it's <c-l> which I interpret as <Ctrl>+l but pressing that does nothing. I have to press ENTER on the folder (to close it) and then again (to open it) to see the file has been copied. I was hoping <c-l> would've have worked but it doesn't error or anything?

Penn Su

unread,
Aug 16, 2017, 3:16:52 AM8/16/17
to vim_use, Charles.E...@nasa.gov
I'm having the same issue where doing it via the intended netrw commands gave me the error but if I do it via command such as
:!cp file.txt file2.txt

it worked.
Reply all
Reply to author
Forward
0 new messages