Window stacking in VIM

Stolen shamelessly from this site.

map <c -J> </c><c -W>j</c><c -W>_
map </c><c -K> </c><c -W>k</c><c -W>_
set wmh=0
</c>

The first two lines allow you to switch between splits much more smoothly — just press to open and maximize the split below the current one and to open and maximize the split above the current one. I chose these mappings because they correspond to vi’s default up and down keys, you might want to use different key combinations if you’ve ever used an editor that had hotkeys for moving from one open file to another.

The last line allows splits to reduce their size to a single line (which includes the filename and position); this saves a lot of space when you have many splits open. By default, vim forces splits to include an additional line that contains the line of text the cursor was on in that file.

This gives you some sort of stacking functionality like in wmii

Leave a Reply