1

After going through the renaming guides from the doc folder in vim I found a way to replace text with the input :%s/frompattern/topattern/g. Reaching the renaming files with the file browser tutorial/guide I managed to learn the MR and R method stated in the netrw-R help file.

Then I tried to use the text replacing method on multiple files like so:

:set ma
:%s/frompattern/topattern/g

All the files changed after backspacing the : requested from the notification

"Press Enter or Type Command To Continue".

All files changed unfortunately those changes have only been made inside vim , no files have been altered.

Is there a way to apply the changes after renaming them that way or is that input strictly for text inside a file/document ?

Trying to exit vim through :x assuming it would apply changes gives me:

E45: 'readonly' option is set (add ! to override)
Press Enter or Type Command To Continue

Trying to exit with :x! gives me:

"/home/user/VimLearning/"
E502: "/home/user/VimLearning/" is a directory
Press ENTER or type command to continue 

I can only exit with :qa!

This post explains the same technique as the NetRw-R help file but better in my opinion.

But the question remains as to renaming multiple files via :%s/frompattern/topattern/g and applying those changes. Would it be possible ?

Thanks for all the answers , I am really enjoying learning Vim and the QMV suggestion that was posted here. In the NetRw-R help file there is this info:

The g:netrw_rename_cmd variable is used to implement remote renaming. By default its value is:

ssh HOSTNAME mv

One may rename a block of files and directories by selecting them with V (linewise-visual) when using thin style.

The latter is what I am interested in. Renaming a block of files and directories. There are no examples. Would anyone be kind enough to point me towards one ? Or has that feature been removed or it is only for the renaming of remote files and folders as the text above it would mention ? Would that work the same as QMV ? Thank you guys , this community has been very helpful.

3
  • 1
    I would use external tools like vidir, qmv and the such for that. Or vifm file manager.
    – Maxim Kim
    Sep 23 at 6:35
  • Welcome to Vi&Vim SE....and to Vim! :)
    – B Layer
    Sep 23 at 10:52
  • As I pointed out in the answer, netrw can't do mass renames as qmv or emacs dired do.
    – Maxim Kim
    Oct 13 at 13:42
0

Netrw doesn't support file renames based on buffer changes (the way emacs dired does it).

There are external tools like vidir and qmv that runs vim (to be precise EDITOR) with directory contents where you can change filenames to be renamed "en masse".

It looks like this:

enter image description here

PS, you can also run it from within vim using built-in terminal: :term vidir

2
  • Note that qmv is part of the package known as renameutils. These are some excellent tools. Use qmv and qcp for bulk operations. Also check out icp and imv. When used in conjunction with set -o vi an alias like alias mv='imv --pass-through' is a nice convenience with a Vim flavor. :)
    – B Layer
    Sep 23 at 11:21
  • The Batchy plugin from Martijn is pretty great imo
    – D. Ben Knoble
    Sep 23 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.