I know it's possible to open a new file in a split, with :split or :vsplit, but is it possible to open a new split with an existing buffer, potentially leveraging autocomplete?

  • 1
    Have you ever tried :sp(lit) or :vs(plit) with no argument? :) – yo' Feb 3 '15 at 18:57

The sbuffer command will let you create a split with an existing buffer name or number. :sb# will open a split with buffer number # (as displayed in the :buffers list). :sb foo will open a split with the buffer named foo. Tab-complete will cycle the available buffer names.

You can use :vertical sb... if you want a vertical split instead of the default, horizontal, one.

| improve this answer | |
  • Is there a less verbose way to open an existing buffer in a new vertical split? Something like :v sb maybe? – zepp.lee Apr 28 '18 at 13:52
  • 1
    I believe “vertical” can only be shortened to “vert” so if you want something more concise you’ll have to make a custom command/function/etc – user72 Apr 28 '18 at 14:14
  • I use this mapping to do the job. ls lists all opened buffers, so you don't have to remember the name :) nnoremap <leader>vb :ls<cr>:vertical sb<space> – Mattia72 Feb 3 at 7:33

:(v)split <name_of_buffer> or :(v)split #<buffer_number>

This answer shows a shorter way to @user72's answer above and @zepp.lee's comment.

For example, you can open buffer 2 in a vertical split with

:vsp #2


:vsp test.js
| improve this answer | |
  • 1
    Welcome to this site @alexhg! We encourage our users to create detailed answers to make sure they are as useful as possible to other readers: here it would be useful if you explained why you suggest using this solution, you could also link to the doc. For now your answer has been flagged as being "low quality" but you can use the "edit" button to fix that. – statox Sep 2 '19 at 18:29

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.