How do I open the alternate buffer in a new split while keeping my current window unchanged?
Answer
:leftabove sbuffer #
Explanation
If you often compare your current file against the previously visited buffer, replacing the current window is disruptive. :leftabove sbuffer # opens that alternate buffer in a new split above the current one, preserving your active editing context. It is a precise workflow for code review, side-by-side diff prep, or cross-referencing without retyping buffer names.
How it works
:leftaboveis a split modifier that controls placement of the new windowsbufferopens an existing buffer in a split instead of replacing the current window#is the alternate-buffer marker (same target used by<C-^>)
Unlike opening by filename, this uses Vim's buffer state directly. That means no path completion and no disk reload when the alternate buffer is already loaded.
Example
You are editing service.go, and handler.go is your alternate buffer from the last jump.
Current window: service.go
Alternate (#): handler.go
Run:
:leftabove sbuffer #
Result:
Top split: handler.go
Bottom split: service.go
Your current edits remain visible, and you can move between both files with normal window motions.
Tips
- Use
:rightbelow sbuffer #when you prefer the new split below - Combine with
:set splitbelow splitrightfor predictable layout defaults - Use
:lsif#is not the buffer you expected