Change split orientation
Splitting your screen in Vim is a powerful way to compare to files, work on code side-by-side with its test, or just get more done. Pro Vim users work more efficiently by having multiple files open and on screen at once. Vim has a number of commands you should internalize for working with splits, some of which we’ve covered before:
But one I often need and always forget is how to switch splits from side by side orientation (vertical splits) to top and bottom orientation (horizontal splits). To change your split orientation use the command that prepends all split commands:
ctrl-w followed by either K or H:
- ctrl-w H – Change horizontal splits to vertical
- ctrl-w K – Change vertical splits to horizontal
" change vertical to horizontal with - noremap <c-w>- <c-w>t<c-w>K " change horizontal to vertical with | noremap <c-w>\| <c-w>t<c-w>H
This will map
ctrl-w - to switch vertical splits to horizontal ones. And
ctrl-w | will change horizontal splits to vertical ones. The character choice is designed to help you remember them, but do note that these will overwrite some existing split commands so might not be the best choices. You can always choose different key mappings, simply change the first argument to another choice.
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?