How do I open the current buffer in a new tab so I can view it independently?
Answer
:tab split
Explanation
:tab split opens the current buffer in a brand new tab page, giving you a second independent view of the same file. Unlike :tabnew (which opens an empty tab) or :tabedit filename (which opens a different file), :tab split duplicates your current window into a tab without changing any buffers.
How it works
:tabis a command modifier that tells Vim to open the result in a new tabsplitnormally creates a horizontal split of the current buffer in the same tab- Combined as
:tab split, it creates that split but places it in a new tab instead - The cursor position is preserved — you land on the same line you were on
Example
You're deep in a large file and want to open a second view at a different location while keeping your place:
:tab split
" Now in a new tab with the same buffer
" Navigate freely here without disturbing your original position
gt " switch back to the original tab
Tips
- Both tabs share the same buffer — edits in one are reflected in the other
- This is useful for reading one section of a file while editing another
:tabworks as a modifier for many split commands::tab sb 3opens buffer 3 in a new tab- To move the current window to its own tab instead of duplicating it, use
<C-w>T - Close the duplicate with
:tabcloseor navigate away withgt/gT