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 prefixT(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
gtto go to the next tab andgTto go to the previous tab - Use
:tabcloseto close the current tab and return to the remaining ones - Use
:tabnew filenameto 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 filenameor: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