Swap vim splits from horizontal to vertical

#Vim

I was pairing with a coworker the other day when they asked:

How do I swap this Vim split from horizontal to vertical?

Visually, they wanted to do this:

+----------------------+      +------------+-------------+
|                      |      |            |             |
|          A           |      |            |             |
|                      |      |            |             |
+----------------------+  ->  |     A      |      B      |
|                      |      |            |      👋️     |
|          B           |      |            |             |
|          👋️          |      |            |             |
+----------------------+      +------------+-------------+

A simple question with several different solutions1.

My prefered way to reposition panes is to use window move commands2 From normal mode press Ctrl-w, then H, J, K, or L to send the current pane to a far side. Note the capital HJKL, which correspond to left, bottom, top, or right.

To move Split B from the bottom to right, use Ctrl-w L

Ctrl-w H would put Split B on the left vertical split.

Writing this down in case it helps someone else out there 🤘️

  1. There are always lots of ways to do these things, including Ctrl-w x, which will exchange windows when there are not multiple splits open 

  2. See :help window-moving