Search code examples
vim

Split and find file in Vim like :sf but vertically


I use :sf <filename> with Vim a lot, to split horizontally and edit the said file in the new window.

I wonder what's the equivalent command to do the same but split vertically rather than horizontally.

:vne seems the closest I can find to this, but the help says it doesn't search for the file like :sf does.


Solution

  • :vert sf <filename>
    

    From :h :vert:

                            *:vert* *:vertical*
    :vert[ical] {cmd}
            Execute {cmd}.  If it contains a command that splits a window,
            it will be split vertically.
            Doesn't work for |:execute| and |:normal|.
    

    Note: The usual way of describing the 'direction' of a split (vertical/horiontal) is by the axis of the split, not the layout of the windows, so you're actually looking for a vertical split here.