How to Edit Multiple files with VIM

This tutorial is a simple technique for editing multiple files in VIM which I stumbled upon very recently.

Suppose you have 3 files you want to edit at a go, you can simply run

$ vim file1.txt file2.txt file3.txt

If you want to edit all the files in a directory, you can cd to that directory and run

$ vim *

While editing the files, you can switch to the next file using the command :next of :n. :wnext can be used to write changes and move to the next file in one go.

To move to previous file run :previous . To save and move to previous file in one go run :wprevious.

To see where you are in the list of files open, run :args

Leave a Reply

Your email address will not be published. Required fields are marked *