A lot of Programmers use Vim in some way or another but a vast majority of them use only a handful of features. Knowing to use Windows/Splits, tabs, macros and marks can really increase your productivity. Through this and the upcoming articles on Vim I will try to cover the important things that make Vim so awesome.

Splitting your Screen

Vim Splits are a very powerful way of keeping your workflow organized. You can use splits (windows or view-ports in Vim vernacular) to get a different view in to the same file or open a different file to see a quick diff .

The advantage of Vim compared to other popular editors is that, they either don't support splitting the screen or have several limitations on how you can split . Vim lets you split the window as much as you want in any number of pieces and also lets you switch between them instantaneously. And, most importantly you have both Horizontal and Vertical splits.
So, if it makes sense,  you can create a really complex split layout like this. (though i would probably advise against it )

vim windows

Or you can just keep it simple with just a couple of splits open. All up to your requirement.

So, Let's see a few things that will get you started with using Split windows in Vim.
To open a file in a Horizontal Split window just type this in,

:sp filename.here <Enter>

To open a file in a Vertical Split window,

:vsp filename.here <Enter>

Now, if you want to open the current file in a new split (horizontal or vertical), just type :sp or :vsp and it will open a new split-view in to the current file.
Here are a few things that will make using splits much easier.
You probably want to put these in your vimrc file.

Easy 'split' navigation
nnoremap  h
nnoremap  j
nnoremap  k
nnoremap  l

This will make switching from one split to another really easy and intuitive. So, <Ctrl + h> moves the cursor to the left split just as 'h' would move it to the left character. Similarly for others.
Another thing i really like to do is resizing the Splits. I have the following in my vimrc for easy resizing.

Easily resize the splits
nnoremap  :vertical resize +5
nnoremap  :vertical resize -5
nnoremap  :res +5
nnoremap  :res -5

So, to resize your vertical split to the right, press Ctrl + <Right-Arrow> and similarly for others.

Another mapping that I use almost every day is mapping my <Right-Arrow> to open up a new vertical split. I absolutely love this and use it when ever i want a quick diff of two files or just to open two views of the file in the buffer.
nnoremap <right> :vsplit <CR> So, these are the basic things that you need to know to start using Splits in Vim. For more info on Splits and buffers use the Vim's default help :help windows

That is all for this post. Stay tuned for the next one .
Happy Vimming!