How do I open a specific buffer in a new split without navigating away from my current buffer?
Answer
:sbuffer {N}
Explanation
:sbuffer {N} opens buffer number N in a new horizontal split, leaving your current window untouched. This is a fast way to bring a second file into view when you already know its buffer number from :ls.
How it works
:sbuffer(abbreviated:sb) splits the current window horizontally and loads the specified buffer{N}is the buffer number shown by:ls- You can also use a partial filename instead of a number:
:sb partial-name - For a vertical split, use
:vertical sbuffer {N}(or:vert sb {N}) :sbnextand:sbprevsplit and cycle through the buffer list
Example
Run :ls to view open buffers:
1 %a "server.go" line 42
2 h "handler.go" line 1
3 h "models.go" line 1
To open models.go (buffer 3) in a vertical split beside your current file:
:vert sb 3
Both files are now visible without any intermediate navigation.
Tips
- Combine with
<C-w>=after opening to equalise window sizes :tab sbuffer {N}opens the buffer in a new tab instead of a split:sballopens all loaded buffers in splits at once — useful for a quick multi-buffer review- Use
<C-^>to toggle between the two most recent buffers within the same window