How do I open the next buffer in a new split window without leaving the current one?
Answer
:sbnext
Explanation
:sbnext (shorthand :sbn) opens the next buffer from the buffer list in a new horizontal split, leaving your current window and buffer intact. It is the split counterpart of :bnext — instead of replacing the current window, it creates a new one. Similarly, :sbprev (:sbp) opens the previous buffer in a split.
Commands
:sbnext/:sbn— split and switch to the next buffer in the list:sbprev/:sbp— split and switch to the previous buffer:sbfirst— split and open the first buffer:sblast— split and open the last buffer:sb {N}— split and open buffer number N:sb {name}— split and open the buffer matching{name}(partial name OK)- Use
:vertical sbnextor:vert sbnfor a vertical split instead
Example
You are editing main.py and want to compare it with the next file in your buffer list:
:sbnext
Now you have main.py in the bottom window and the next buffer in the top window.
Open the previous file in a vertical split:
:vertical sbprev
Tips
- All
:s{buf-cmd}forms obey the same:verticalprefix for vertical splits - Combine with
<C-w>=to equalize the split sizes after opening :sb {partial}with<Tab>completion is fast for jumping to a specific buffer by name in a split- To cycle through all buffers each in their own split window:
:ballopens all buffers in tiled splits at once