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

How do I open a file in a new tab in Vim?

Answer

:tabedit

Explanation

Vim's tab pages let you keep separate window layouts open at the same time, each with its own set of splits. Opening a file in a new tab gives it a clean, full-screen workspace without disrupting the splits you already have in other tabs.

How it works

  • :tabedit {filename} (abbreviated :tabe) opens the named file in a new tab page.
  • :tabedit with no argument opens a new, empty buffer in a new tab.
  • :tabnew is an alias that does the same thing.
  • Navigate between tabs with gt (next tab) and gT (previous tab), or :tabnext / :tabprevious.
  • Close the current tab with :tabclose (:tabc).

Example

:tabe config.lua       " open config.lua in a new tab
:tabe                  " open a blank new tab

" Navigate tabs:
gt      " go to next tab
gT      " go to previous tab
3gt     " go to tab number 3

Tips

  • :tabs lists all open tabs and their windows.
  • :tabonly closes all tabs except the current one.
  • You can open multiple files in separate tabs at startup: vim -p file1.txt file2.txt.
  • Tabs and buffers serve different purposes: buffers hold file content, tabs hold window arrangements. For quick file switching, :bnext/<C-^> is usually faster; tabs shine when you need isolated screen layouts.

Next

How do I visually select a double-quoted string including the quotes themselves?