Using VI To Edit Two Files In A Split Screen

Subject:

references: http://www.philchen.com/2007/04/13/using-vi-to-edit-two-files-in-a-split-screen

Sometimes you need to edit a new or existing file while looking at a separate file using VI. This can be very useful and a powerful time saver. Fortunately you can do this using some simple commands.First go ahead and edit a file with VI

shellprompt$ vi test-1.txt

while in VI enter the following

:new

This will open a new split screen session, in order to navigate between the two windows in VI do the following

<ctrl-w> j

Or

<ctrl-w> k

Using the first will move you to the lower window and using the latter will move you to the upper window.

To make one of the windows full screen and out of the dual screen mode use the following

:only

*Important Side Notes

If you used :new and opened up a new window session it will not have a name so you cannot save it without entering the following

:wq whatevername.txt

Also if you want to open a file in split screen mode that is not new and exists you can enter the following

:new /path/to/whateverfile

Happy Editing!

2015-10-19 21:12:52gstlouis