How to work on multiple files in single VIM editor


Open the file using the VIM editor.

vim test1.txt

Now if you want to open another file and also want the test1.txt to stay open, just press Esc and then :sp “your_file” (without quotes). This will split the window and open ‘your file’ along with ‘test1.txt’. You now have two files open in the same VIM editor. Using sp(Split) you can open multiple files.

:sp test2.txt

:sp welcome.txt

This will split the screen whenever you open a new file using sp. You can select the file pressing CTRL+w+w. You have to do this till you reach the specified file you want.

The window will be split into small parts. For more readability, you can enlarge the specified file using the on command. Press Esc and type:

:on

The file you are in will be maximised, and the rest will not be visible. After making all the files visible, apply the command ba. Press Esc and type:

:ba