Linux / Unix vi / vim: Open and Switch Between Multiple Files

To open multiple files in vi/vim editor, you can use the following command:

vim file1 file2 file3

Once you have multiple files open, you can switch between them using the following commands:

:n # go to the next file
:N # go to the previous file
:bn # go to the next file in the buffer
:bp # go to the previous file in the buffer
:b <number> # go to the specified buffer number
:b <filename> # go to the buffer with the specified file name

Leave a Comment