Table of Contents

How To Rename Multiple Files Using Vim

In this post we will talk about vim and vim plugins to rename multiple files.

For this exercise. I will create dummy files.

mkdir test
cd test;touch file1 file2 file3
file1  file2  file3

How to use vimv to rename files

lets first install vimv using following command.

mkdir -p ~/bin/;curl -XGET > ~/bin/vimv && chmod +755 ~/bin/vimv
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   944  100   944    0     0  10260      0 --:--:-- --:--:-- --:--:-- 10260

Ok once it is installed. Lets rename the files we created above using vimv

To rename the files either type vimv or vimv file* on your bash command prompty. You would get following file names opened in the vimv editor. Follow the steps shown in the snapshots below.

Lets change the file names to f1, f2 and f3

Lets now save the file using :wq


As we see the file names have changed. Lets do unix ls to check.

f1  f2  f3

How to rename files in vim using vim plugin vim-renamer

Lets install it using pathogen.

cd ~/.vim/bundle
git clone

Now you have vim-renamer installed. Make sure you are outside the test directory. Open vim and type :Renamer test.

You should see below output.

To rename the files do :Ren. I am changing f1 to file1 and f2 to file2 and leaving f3 as it is. Remember dont remove f3, otherwise it will delete the f3 on exiting the vim.

Now get out of vim. You would see your file names have changed. Lets do ls to check that.

ls test/
f3  file1  file2

As we see above f1 and f2 have been renamed to file1 and file2 and f3 name is not touched.

How to rename files in vim using vim utility mvim

This utility is similar in usage to vimv. This requires python version 3.6 and above

Lets install it first.

cd /tmp/;git clone;cd mvim;python install

Go inside the directory where your files are.

f3  file1  file2

Lets rename the above files using mvim. Do following...

mvim f*

You would see list of files.

Lets change all these file names to new names as shown below. Save and exit out of tile using :wq

You should see following output.

Related Posts