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

How do I show the current buffer in a new tab without re-reading it from disk?

Answer

:tab sbuffer

Explanation

Sometimes you want a second workspace for the same file: one tab for broad navigation, another for focused edits or test-driven jumps. Reopening by filename can trigger avoidable path friction, and switching windows can disrupt your current layout. :tab sbuffer opens the current buffer in a new tab page directly from the buffer list, so you get another view on the same in-memory buffer state.

How it works

  • :tab runs the following command in a new tab page
  • :sbuffer opens a buffer in a split-like way without reloading from disk
  • With no explicit argument, :sbuffer uses the current buffer
  • Both tabs now share one buffer: edits in one are instantly visible in the other

Example

Start in app/router.lua, then run:

:tab sbuffer

Now you can keep one tab near route declarations and another near handler implementations. If you edit in one view, the other reflects those changes immediately because they point to the same buffer.

Tab 1: top-level route table
Tab 2: deeply nested handler logic

Tips

  • Pair this with distinct folds or cursor positions per tab for context switching
  • Use :tabclose when done; the buffer remains if referenced elsewhere
  • If you need a different file in a new tab, use :tabedit {file} instead

Next

How do I run a one-off macro without recording by executing keystrokes from an expression register?