According to following thread on the mailing list vim_use from 03.10.15
(https://groups.google.com/forum/#!topic/vim_use/6yqU3RX2CWA):
How to copy and rename a file with netrw where the target and source directory are the same?
answered by the author of netrw DrChip himself:
Copy a file using the usual netrw method for copying: (assuming cursor
is atop the file to be copied, and that the file is a file, not a director)
mt (mark target)
mf (mark file)
mc
You'll be given a prompt: Copy [filename] to : [filename]
Just edit the 2nd instance of [filename]
to whatever you want, then hit <cr>
.
Regards,
Chip Campbell
UPDATE
I can confirm that the issue raised on the mailing list also still exist for me. Sorry for not testing before mentioning this thread! The error message is
**error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!
OS: macOS 10.12
Vim: 8.1.0280 (MacVim Release 151)
Netrw: v156 (doc claims v162, but file is still v156)
As described you should be able to avoid the issue by either setting in general
let g:netrw_keepdir=0
(default value is 1
) in your vimrc, or
- press first
cd
(netrw v162) (formerly c
v156) and then mt mf mc
Unfortunately, I still experience an error:
**error** (netrw) copy failed; perhaps due to vim's current directory</Users/hotschke/.vim-configs/main> not matching netrw's (/Users/hotschke/.vim-configs/main/) (see :help netrw-c)
The obvious difference is a missing final slash and the surrounding brackets. I would really hope that netrw could be improved to support this regardless of the setting g:netrw_keepdir
.
Note
:!cp...
command if you first do acd
in the netrw window to change the current directory. You do need to refresh the netrw window though, else the new file won't appear.