I have some files in my vim buffer.

:ls shows the list of active buffer, I want to open a file from buffer into a vertically/horizontally split window.

I know :vsp or :sp open split window in vim but how to open a split window from files in buffer?

  • Those are "buffers" (not "files") and they are in your "buffer list" (not "buffer"). – romainl Jun 7 '16 at 16:15
  • But they represent files which have been recently opened. Right? – WitVault Jun 7 '16 at 19:12
  • Related: see :h gf and :h CTRL-W_f. – Sato Katsura Jun 7 '16 at 20:49
  • No, they represent "documents" that may or may not be associated to actual files. – romainl Jun 7 '16 at 21:54

You can give

:vsplit | buffer buffernumber/buffername

to open a buffer in vertical split mode.


:split | buffer 3

Same applies to horizontal split mode too. You can use :sp as a shortcut for :split and :vs for :vsplit


You can do :2sbN or :sbN 2 to split the window and go to the 2 buffer. To split the window vertically, you can use :vert sbN 3 to go to buffer 3.

An alternative solution is to use the :sp [+cmd] syntax. To vertical split the window and go to buffer 10 you would then use :vsp +b10.

  • It will be better if you could include the syntax for opening buffer through its name – SibiCoder Jun 7 '16 at 16:14
  • the syntax is explained in the help – Christian Brabandt Jun 7 '16 at 17:33
  • Why use :sbN over :sb? I fine :sb to be very hand as you can use partial filenames. – Peter Rincker Jun 7 '16 at 18:35
  • What is the meaning of :sb in understandable terms? – WitVault Jun 7 '16 at 21:18
  • I think its split buffer. – SibiCoder Jun 8 '16 at 3:31

:sp and :vs take a filename as argument.

So you can do :sp filename and :sp filename.

The doc :h :sp says:

:[N]sp[lit] [++opt] [+cmd] [file]

If [file] is given it will be edited in the new window. If it is not loaded in any buffer, it will be read. Else the new window will use the already loaded buffer.

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.