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

How do I move a split window into its own tab?

Answer

<C-w>T

Explanation

The <C-w>T (Ctrl+w then Shift+t) command moves the current split window into a new tab page. This is perfect when you have a split that you want to focus on full-screen without closing the other windows or losing your layout.

How it works

  • <C-w> is the window command prefix
  • T (uppercase) tells Vim to break the current window out of its split and place it in a brand new tab
  • The original tab retains all its other splits — only the current window is moved
  • If the current window is the only window in the tab, the command does nothing

Example

You have two files open in a vertical split:

┌──────────┬──────────┐
│  main.go │ utils.go │
│          │ (active) │
└──────────┴──────────┘

With the cursor in utils.go, pressing <C-w>T moves utils.go into its own tab. Now you have two tabs:

  • Tab 1: main.go (full screen)
  • Tab 2: utils.go (full screen)

Switch between them with gt and gT.

Tips

  • Use gt to go to the next tab and gT to go to the previous tab
  • Use :tabclose to close the current tab and return to the remaining ones
  • Use :tabnew filename to open a file directly in a new tab instead of moving a split
  • To do the reverse — move a tab back into a split — there is no built-in command, but you can close the tab and reopen the file in a split with :split filename or :vsplit filename
  • This command is especially useful when you are comparing files in splits but want to temporarily maximize one of them without disrupting the other
  • Use <C-w>= after moving a window out if the remaining splits need to be re-equalized

Next

How do I edit multiple lines at once using multiple cursors in Vim?