How do I force any window-opening command to create a vertical split instead of horizontal?
Answer
:vertical {cmd}
Explanation
The :vertical command modifier forces any window-opening Ex command to create a vertical split instead of the default horizontal split. This is especially useful for commands that always split horizontally and offer no direct vertical variant.
How it works
:verticalis a modifier prefix you can prepend to any Ex command that opens a window- Vim interprets it as an instruction to use vertical layout for the resulting window
- It works even with commands like
:helpand:diffsplitthat don't have a built-in vertical option
Example
Opening help horizontally (default):
:help motion
Opening the same help page in a vertical split:
:vertical help motion
Other useful combinations:
:vertical diffsplit file.txt " diff in a vertical split
:vertical new " new empty buffer in vertical split
:vertical sbuffer 3 " open buffer 3 in vertical split
Tips
:vertworks as a short form::vert help {topic}- Complement with
:topleft,:botright,:aboveleft,:belowrightto also control the split direction (left/right/above/below) - Particularly handy for
:vertical helpsince:helpalways opens horizontally by default and you normally need<C-w>Lto convert it afterward