How to copy and rename a file with netrw where the target and source directory are the same?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to copy and rename a file with netrw where the target and source directory are the same?

Shane Dev
for example, I want to "backup" a file, in bash I type

cp /etc/foo /etc/foo.0

can I achieve the same time with netrw?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to copy and rename a file with netrw where the target and source directory are the same?

Charles E Campbell Jr
Shane Dev wrote:
> for example, I want to "backup" a file, in bash I type
>
> cp /etc/foo /etc/foo.0
>
> can I achieve the same time with netrw?
>
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

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to copy and rename a file with netrw where the target and source directory are the same?

Shane Dev

> 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
Hi Chip,

When do this, I get an error window with
**error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!;

I am using vim 7.4

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to copy and rename a file with netrw where the target and source directory are the same?

Charles Campbell
Shane Dev wrote:

>> 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
> Hi Chip,
>
> When do this, I get an error window with
> **error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!;
>
> I am using vim 7.4
>
Netrw depends on the o/s to do a lot of things, including copying
files.  In this case, it is trying to use the "cp" command and its
failing when a system() call is taken...

      call system(g:netrw_localcopycmd." ".shellescape(fname)."
".shellescape(topath))

fname will hold the file's name that's to be copied, and
topath holds the target directory (and filename).

or an isexecutable(g:netrw_localcopycmd) indicates the command is not
executable.

Translated: put whatever your system uses for copying files as a command
and enter it into g:netrw_localcopycmd.  You may wish to modify the
other, related variables, too:
g:netrw_localmovecmd, g:netrw_localcopydircmd, g:netrw_localrmdir, etc.

If you're using windows, you ought to upgrade netrw (see
http://www.drchip.org/astronaut/vim/index.html#NETRW) because it has an
improved way to get windows to do what's wanted (fyi: using $COMSPEC).

Regards,
Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to copy and rename a file with netrw where the target and source directory are the same?

Shane Dev
Hi Chris,

I appreciate the netrw author taking an interest in my newbie problem - but I am still stumped. I am running gvim 7.4.884 on Arch Linux. I checked some global variables -

:ec g:loaded_netrwPlugin
v153
:ec g:netrw_localcopycmd
cp
:ec executable(g:netrw_localcopycmd)
1

then I launch netrw on a directory which I have read/write permissions
mt
mf
mc
entered new file name
**error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!

any clues?

On Monday, 5 October 2015 22:35:38 UTC+2, Charles Campbell  wrote:

> or an isexecutable(g:netrw_localcopycmd) indicates the command is not
> executable.
>
> Translated: put whatever your system uses for copying files as a command
> and enter it into g:netrw_localcopycmd.  You may wish to modify the
> other, related variables, too:
> g:netrw_localmovecmd, g:netrw_localcopydircmd, g:netrw_localrmdir, etc.
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How to copy and rename a file with netrw where the target and source directory are the same?

Charles Campbell
Shane Dev wrote:

> Hi Chris,
>
> I appreciate the netrw author taking an interest in my newbie problem - but I am still stumped. I am running gvim 7.4.884 on Arch Linux. I checked some global variables -
>
> :ec g:loaded_netrwPlugin
> v153
> :ec g:netrw_localcopycmd
> cp
> :ec executable(g:netrw_localcopycmd)
> 1
>
> then I launch netrw on a directory which I have read/write permissions
> mt
> mf
> mc
> entered new file name
> **error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!
>
> any clues?
>
There's one place in the netrw plugin that issues that message; it
means, for whatever reason, the system() command is failing (and setting
v:shell_error; line 6637 in version v154h).

What does

:call system("cp 'oldfilename' 'newfilename'")

do?  (where oldfilename is an actual filename).  Also see  :help
netrw-debug.

Regards
Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

WORK AROUND: How to copy and rename a file with netrw where the target and source directory are the same?

Shane Dev
Hi Chris,

:cd [the directory of oldfilename]
:call system("cp 'oldfilename' 'newfilename'")

works as expected.

After further testing, it seems I have to execute netrw-c (make browsing directory the current directory) before the sequence -

1. move cursor to oldfile,
2. mt
3. mf
4. mc
5. enter newfilename.

If I execute :cd (change to home directory) and repeat the above sequence, then I get -

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

Is this part of netrw design?


> What does
>
> :call system("cp 'oldfilename' 'newfilename'")
>
> do?  (where oldfilename is an actual filename).  Also see  :help
> netrw-debug.
>
> Regards
> Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: WORK AROUND: How to copy and rename a file with netrw where the target and source directory are the same?

Charles Campbell
Shane Dev wrote:

> Hi Chris,
>
> :cd [the directory of oldfilename]
> :call system("cp 'oldfilename' 'newfilename'")
>
> works as expected.
>
> After further testing, it seems I have to execute netrw-c (make browsing directory the current directory) before the sequence -
>
> 1. move cursor to oldfile,
> 2. mt
> 3. mf
> 4. mc
> 5. enter newfilename.
>
> If I execute :cd (change to home directory) and repeat the above sequence, then I get -
>
> **error** (netrw) tried using g:netrw_localcopycmd<cp>; it doesn't work!
>
> Is this part of netrw design?
>
Yes; you can change the current directory behavior by setting
g:netrw_keepdir= 0 in your .vimrc.

Vim v6.x's Explorer always kept the vim current directory separate from
its  browing directory -- netrw supports backwards compatability by also
doing so, by default; however, it lets you change that behavior.  I,
personally, prefer to have netrw's browsing directory and vim's current
directory be the same, myself.

Glad you found the problem, though.

Regards,
Chip Campbell

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.