As title. And I also need to know how to specify a tab to move to. So I expect the syntax would look like this:

:movebuf <buffer_id> <tab_id>
  • 1
    is it enough to open the buffer in the other tab, then close it in the current one?
    – Mass
    Dec 4, 2022 at 21:44
  • 1
    What about :bun<CR> {N}gt :sb {buffer_name}?
    – husB
    Dec 5, 2022 at 2:45
  • @Mass That should work. At the moment I was asking about this, I thought this can be achieved by a single command. Feb 6, 2023 at 14:22

1 Answer 1


There is currently no command or function in vim which is capable to actually move windows to another tab (that is, including the window's history, settings, and all other information).

The built-in approach is to use ctrl-w T which means to move the window to a new tab. However, this does not work for existing tab pages, and does not work if the current tab only contains one window. Also, it does not preserve window variables (w:...)

Since the question asked about "moving a buffer," we can instead assume that we're accepting closing the current window and creating a new window with the same buffer. Here is one prototype (untested) implementation

command! Movebuf -nargs=+ :wincmd c
    \| call execute('tabnext ' . <f-args>[1])
    \| call execute('sbuffer ' . <f-args>[0])
  • So after the buffer to move is opened in a new window, I can assume that things like <C-o> and <C-i>(jump history? I don't know what's the name) would work on that new window, right? Feb 6, 2023 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.