Vim: vnew, but receiving a buffer instead of a file name?

Currently, if I want to create a new window, load the buffer I use :vnew :buf foo.py. Is there one command that will execute both?

+3
source share
2 answers

Yes, there is a command for this:

:[N]sb[uffer] [N]                   :sb :sbuffer
        Split window and edit buffer [N] from the buffer list.  If [N]
        is not given, the current buffer is edited.  Respects the
        "useopen" setting of 'switchbuf' when splitting.  This will
        also edit a buffer that is not in the buffer list, without
        setting the 'buflisted' flag.

You may also find them useful:

:[N]sbn[ext] [N]                                    :sbn :sbnext
        Split window and go to [N]th next buffer in buffer list.
        Wraps around the end of the buffer list.  Uses 'switchbuf'

:[N]sbN[ext] [N]            :sbN :sbNext :sbp :sbprevious
:[N]sbp[revious] [N]
        Split window and go to [N]th previous buffer in buffer list.
        Wraps around the start of the buffer list.
        Uses 'switchbuf'.

The problem with both teams is that they will split horizontally. You can precede them with help :vert[ical], but this violates your one command paradigm :-)

In any case, it :vert sb foo.pydoesn't print much, and if you really use it often, you might want to create a map for it. Maybe something like:

cnoremap ,sb vert sb 
+3
source

Just tell :vnewthe file path:

:vnew foo.py

Edit:

sidyll, , , ex, , :

command! -nargs=1 -complete=buffer -bang Vbuffer vnew | buf<bang> <args>

! command :Vbuffer, ( , ), -nargs=1 , 1 , :buf <args>, -complete=buffer tab -bang , !, :buf <bang>.

~/.vimrc :source.; -)

+1

All Articles