The Computer Oracle

Is there a way to move a split page to a new tab in Vim?

--------------------------------------------------
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------

Take control of your privacy with Proton's trusted, Swiss-based, secure services.
Choose what you need and safeguard your digital life:
Mail: https://go.getproton.me/SH1CU
VPN: https://go.getproton.me/SH1DI
Password Manager: https://go.getproton.me/SH1DJ
Drive: https://go.getproton.me/SH1CT


Music by Eric Matyas
https://www.soundimage.org
Track title: Darkness Approaches Looping

--

Chapters
00:00 Is There A Way To Move A Split Page To A New Tab In Vim?
00:12 Answer 1 Score 4
00:28 Accepted Answer Score 94
00:44 Answer 3 Score 2
01:43 Thank you

--

Full question
https://superuser.com/questions/117969/i...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#vim #gvim

#avk47



ACCEPTED ANSWER

Score 94


Very easily, use CTRL+W, SHIFT+T.

See the help page:

:help CTRL-W_T

Note that this is case sensitive: <C-W>T is different to <C-W>t.




ANSWER 2

Score 4


The long-and-straight-forward way would be to open a new tab and open the file's buffer there.

:tabnew
:b FILE_NAME

:b can TAB-complete from arbitrary parts of the file name, so this shouldn't take too long.




ANSWER 3

Score 2


Canonical Solution

Suppose there are two buffers:

:ls
  1 #h   "match_this_partially.md"  line 1
  2 %a   "food/tacos.txt"           line 1

You currently have food/tacos.txt open. You want to open match_this_partially.md in a new tab.

Simply use the following:

:tab sb partial

-- or --

:tab sb 1

You can also use wildmenu tab completion in place of partial.


long form:

  • :tab sbuffer {buffer}

help:

  • :help :tag
  • :help :sbuffer

Alternative Keyboard Solution

Open file in a new split open it in a new tab with the following:

<c-w>T

Use case

Note: for me ]b simply is mapped with nnoremap <silent> ]b :silent execute v:count.'bnext'<cr>

If I have few buffers I might do something like this:

  1. <c-w>v -- create a new vertical split
  2. ]b -- navigate to next buffer (essentially with :bnext)
  3. <c-w>T -- open split in new tab (this destroys the split in the first tab)