Vim is no doubt a very powerful command line text editor, but it's not easy to master. The tool offers a sea of features, which is why remembering each and every functionality isn't an easy task.

However, it's always good to know the features that are helpful in your day to day task. One such feature - that I am sure most of you'd find beneficial - is the ability to open multiple files in one go, and to be able to switch between those files seamlessly.

In this tutorial, we will discuss how you can do this. Please be aware that all examples/instructions mentioned in this article/tutorial have been tested on Ubuntu 16.04LTS, and the Vim editor version we've used is 7.4.

Open multiple files and easily switch between them

This is very easy - all you have to do is to use the -p command line option. For example:

vim -p file1 file2

The following screenshot shows how the two files opened in single Vim window:

vim-multiple-files

As you can see, the files opened in different tabs. To switch from one tab to other, you can use the :bn and :bp commands while the editor is in the command mode.

That's it. In case you want to learn more about Vim (including advanced stuff), you can head here.

How to open multiple files using single Vim editor command in Linux

Leave a Reply

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

*