In vim, I can find a file and open it in a new tab using :tabfind
, and I can open a file I know the location of in a new split using :split
or :vsplit
. However, I would like vim to find files for me in my path when running the :split
or :vsplit
commands. For example, say in my current directory, I have these files (all of which are in my path):
./ReallyLongFileName1.txt
./fooDir/ReallyLongFileName2.txt
./barDir/bazDir/ReallyLongFileName3.txt
I would like to type the following command in vim:
:vsplit R<Tab>
And have vim search in my path for all files that match that expression, and fill the rest of the line with
:vsplit ReallyLongFileName
This works perfectly with :find
or :tabfind
, but it doesn't work when splitting. Is there a command that does this that I just don't know about, or is there some way to add this functionality to the :split
and :vsplit
commands?
Vim offers several commands for searching for files by name: :find, :sfind, :tabfind on the command-line, several normal-mode commands like gf, and others. If you just enter :find filename , Vim will directly open the first file found in your 'path' matching "filename".
Suppose you have opened a file on Vim editor and you want to split it vertically. To achieve this: Enter command mode by pressing the ESC button. Press the keyboard combination Ctrl + w , followed by the letter 'v' .
As romainl said, :sf
is the command that performs this action. There is no vertical split find, although you can do the same thing with the slightly longer command :vert sf
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With