DEV Community

Colin Bartlett
Colin Bartlett

Posted on • Originally published at vimtricks.com

VimTrick: Moving Splits

Another Monday means another VimTrick!

You may be familiar with Vim’s split capability which allows splitting your screen vertically, horizontally, or both. (If not, see :help split for an overview.) Once you have split your screen, how can you rearrange your splits? It’s easy with ctrl-w:

  • ctrl-w J moves the active to the top

  • ctrl-w H moves the active split to the left

  • ctrl-w K moves the active split to the bottom

  • ctrl-w L moves the active split to right

  • ctrl-w r rotates splits to the right/down

  • ctrl-w R rotates splits to the left/up

Here’s a short screencast showing a screen split into 3 horizontal splits:

Vim split moving

In the screencast, we have focus in the top split. First, use ctrl-w r to rotate the splits down/right which moves our in-focus split to the middle. We repeat ctrl-w r to rotate again and our split is on the bottom. Next, we use the opposite movement: ctrl-w R to rotate up/left, which we again repeat to reposition our split at the top. Last we use ctrl-w J to move our split all the way to the bottom, which accomplishes the same thing as ctrl-w r ctrl-w r, but in one less keystroke.

This is really just scratching the surface of split movements and actions, but this one trick can really help reorganize your screen for maximum efficiency. I'm publishing a twice-weekly newsletter called VimTricks if this sort of thing is interesting to you.

Top comments (0)