Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have list of buffers in vim. I can split buffer horizontally using :sb[N] where N is the buffer number. How can I split the buffer vertically ?

share|improve this question
add comment

3 Answers

up vote 18 down vote accepted

The vs and vsplit commands take a filename as an argument like :vs somefile to open a file in a vertical split.

To put an existing buffer in a split window you use the sb# command (where # is the buffer number). Splits in VIM default to horizontal, to change this, prefix your command with vert which forces a vertical split of the next split command.

:vert sb#

Where # is the buffer number

share|improve this answer
    
I know :vsplit. I doesn't seem to take buffer number. –  blacklife Apr 23 '10 at 23:53
1  
I thought it was to easy :P .. try :vert sbN -where N is the buffer number –  kyrisu Apr 24 '10 at 0:12
    
wohoo! It works. –  blacklife Apr 24 '10 at 0:41
    
@blacklife: so the answer is actually ":vert sbN" ? –  akira May 21 '10 at 6:38
1  
Since :sb works with buffer names too, this will also works with buffer names: :vert sb vimrc –  Philipe Fatio Apr 27 '13 at 14:07
add comment

This is a command I created and added to my .vimrc to allow me to open a current buffer in a vertical split

command -nargs=1 Vsb call VsbFunction(<f-args>)

function VsbFunction (arg1)
  execute 'vert sb' a:arg1
endfunction
share|improve this answer
add comment

As kirysu said, but additionally with "positioning the other split".

:vert rightbelow sb otherfile.txt

or

:vert bel sb otherfile.txt

... opens a existing buffer, named otherfile.txt, in a split "right below" the existing one.
In the case of vertical splitting, it means "right side of the existing buffer".

Here you can use the [tab]-key too, to let vim complete the buffer-name!

(see :help :vert too, for further "positioning"-commands)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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