vim tips

Using splits

Very useful to open multiple files on the same screen or the same file at different places. Splits consists of sharing the vim's screen.

There are basically two possibilities :

When starting vim

$ vim -o foo bar = open foo and bar in split
$ vim -O foo bar = open foo and bar in vsplit

When vim is already started

'^' is the CTRL key.

^w s = share the screen horizontally in two
^w v = share the screen vertically in two

How to move inside splits

^w j = select the bottom split
^w k = select the top split
^w + = extend the current split a line
^w - = reduce the current split a line

How to move inside vsplits

^w h = select the vsplit on the left
^w l = select the vsplit on the right
^w > = extend the current split a column
^w < = reduce the current split a column
^w w = switch between splits
^w [up,down,right,left] = select the split

How to move splits

^w H = move on the left
^w L = move on the right
^w K = move on the top
^w J = move on the bottom

How to close splits

^w q = close the current split
^w o = close all the splits but the current