How do I force any split command to open as a vertical split in Vim?
Answer
:vert {cmd}
Explanation
Vim's :vertical modifier (abbreviated :vert) can be prepended to any Ex command that opens a split window to make it open as a vertical split instead of a horizontal one. This is especially handy when using commands that don't have a built-in vertical variant — such as :help, :diffsplit, or :sbuffer.
How it works
:vertis a command modifier, not a standalone command — it alters how the next command behaves- Any command that would normally create a horizontal split becomes a vertical split
- Works with built-in commands and plugin commands alike
Example
Open Vim help in a vertical split instead of horizontal:
:vert help text-objects
Open a numbered buffer in a vertical split:
:vert sb 3
Start a diff against another file in a vertical pane:
:vert diffsplit other_file.txt
Tips
- Combine with
:topleftor:botrightto control where the vertical split appears::botright vert sb 5 - You can also use
:horizontal(:hor) to force horizontal splits when the default would be vertical - If you find yourself always wanting vertical splits for help, add
autocmd FileType help wincmd Lto your vimrc to automatically move the help window to the right