vimtricks.wiki Concise Vim tricks, one at a time.

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

  • :tab is a command modifier that tells Vim to open the result in a new tab
  • split normally 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
  • :tab works as a modifier for many split commands: :tab sb 3 opens 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 :tabclose or navigate away with gt / gT

Next

How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?