I have several open buffers and want to open a buffer in :ls in a new tab or window.

I have found a way to do accomplish this, either by first executing tabnew or C-w v and then selecting the buffer using :b<N>.

Can the same be accomplished using a single command?


Create a new window from a buffer: :sb<N>(horizontally) or :vert sb<N>(vertically).

Create a new tab from a buffer: :tab sb<N> or create a new window and then press <C-W>T.

| improve this answer | |
  • Thank you, this is just what I wanted! – Shuzheng Feb 16 at 16:06

While editing command line a "special" #n (see :h cmdline-special) is replaced with the n-th buffer name. Hence, all of the following work in Vim (:h 42):

:edit #42
:split #42
:tabedit #42

And so on.

| improve this answer | |
  • Thank you, very useful! – Shuzheng Feb 16 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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