" Close a split and then open it in a new tab:
:ca tb let a=bufnr("%")
:command! Tb :let a=bufnr("%") | q | tabnew | exe "b ". a
" Close the current tab and open as a split in another existing tab:
:command! Ts :let a=bufnr("%") | tabprev | sp | exe "b ". a | tabnext | q | tabprev
:ca ts :let a=bufnr("%")
Note these obviously aren't that smart. If you have no splits, its not gonna act quite right. I've made the order open X, then close Y so that vim still has *something* open. Hopefully that means your Vim session won't disappear out from underneath you.
Yep, I just tested it out. Vim doesn't close, and the 'tb' command works fine regardless of the # of windows open. The 'ts' command acts a little funny when there is more than one split open in a tab. It removes one split, sticks it in another tab but doesn't completely remove the other tab b/c there's still a window in it. Not so bad. Just a little wierd.
6 comments:
I know this post was from a long time ago.. but it just about does what I'm looking for. So any idea how to make it move an unsaved buffer from a split to a new tab?
I'm pretty sure that the following will do what you want:
" Turn a split into a tab
:command! Tb :let a=bufnr("%") | tabnew | exe "b ". a | tabp | q | tabnext
" Turn a tab into a split
:command! Ts :let a=bufnr("%") | tabprev | sp | exe "b ". a | tabnext | q
The trick is to make the new space before deleting the old.
T (capital t) is native to Vim and will open the active split in a new tab, closing the split.
Hi Rodrigo,
Thanks for the comment...I looked around the help files and couldn't find any documentation for the 'T' command you were talking about.
Could you point me in the right direction?
I probably meant Ctrl+w, T, but I may have put the ctrl+w under a tag that was escaped by your comment system...
to join a split screen into a tab:
C-w T
Post a Comment