Take the 2-minute tour ×

Is there a way to take an existing window (split) and put it into a new tab?

share|improve this question
add comment

2 Answers

up vote 31 down vote accepted


:tabedit %<CR>
share|improve this answer
Just curious why you included the <CR> with that. –  Swiss Nov 18 '09 at 19:25
For the same reason I did include ":". This is the complete vim keys combination in normal mode and you can use this in 'nnoremap' and in 'nmap' –  Mykola Golubyev Nov 18 '09 at 19:49
This one didn't work for me. It opens the new tab for a second, but then closes it for some reason. Must be some issue with a setting or plugin I have. DrAl's solution below worked though. –  Sean Mackesey Jul 16 '12 at 19:16
This works as well except it clones/duplicates the window to a new tab as opposed to closing it first and then opening it in a new tab. Not a big deal. Just something to be aware of. –  A-Dubb Sep 15 '12 at 1:08
This doesn't move the buffer to a new tab, it just opens the same file in a new tab, but you will not have undo/redo history, etc. –  trusktr Mar 22 '13 at 23:48
add comment

As well as the previously suggested :tabedit approach, a quicker way of doing it is (in normal mode) to hit Ctrl-W Shift-T. Ctrl-W is the general prefix for a wide variety of window manipulation commands.


:help Ctrl-W_T
:help Ctrl-W
share|improve this answer
Note that help Ctrl-W_T takes you to the help entry of Ctrl-W_t (lower case), however, further down the page is the Ctrl-W_T entry (with capital T), saying "Move the current window to a new tab page...." –  Rabarberski Oct 19 '12 at 10:04
@DrAl and how we move a new tab window to split window? –  Ramiz Uddin Dec 6 '12 at 8:54
@RamizUddin There's no simple way of doing this (as it isn't obvious which window you want to split into). However, you can find out the buffer number for your current tab page with :echo bufnr("") and using this number you can split a window with :sp #3 or :sb 3 (assuming the number was 3). You may be able to come up with some mappings or functions to simplify this. –  DrAl Feb 25 '13 at 10:08
How do you move the buffer to a new tab, keeping it's undo/redo state. In other words, I don't want to open the same file in a new tab, I want to literally move the buffer to a new tab, so the edit history can be used in the new tab. If there is no default way to do this, I bet a plugin can be made that adds a new shortcut for doing this that writes the undo history to the swap file for the new buffer. –  trusktr Mar 22 '13 at 23:50
@trusktr I'd imagine that opening the buffer in a new tab with :sb would work, but with recent versions of Vim (>= 7.3) you can also use persistent undo by setting set undodir=/path/to/dir where /path/to/dir is a directory you've created for the purpose and then set undofile. This will allow you quit vim and then restart and still retain the undo/redo state. –  DrAl Mar 25 '13 at 8:31
add comment

Your Answer


