There are certain occasions when you need to work with multiple files simultaneously. Normally when you want to refer to the contents of a file while working on another file, you open two instances of editors side-by-side. But Vim is intelligent enough to open multiple files simultaneously.
To start a horizontal window by splitting the current Vim instance, use the command Ctrl+w+s, or at the command line, use :split. For a vertical split, type Ctrl+w+h, or at the command line, :vsplit. Refer to Figure 4. You can now switch between different split instances using the Ctrl+w+w shortcut. These multiple splits can be further split using the same commands. The split windows act as separate instances of Vim so that we can open and work on different files, side by side.
To exit from a split window, use the Ctrl+w+q shortcut, or at the command line, use :q!
While we're on the subject of split windows, there is a command called vimdifffor viewing the difference between two files. Suppose you have two versions of a text file, and you want to look at the changes made and compare it with the original, use the command.
When you scroll through the file, both file instances will be scrolled. Sounds interesting, right?