When opening files in Vim I almost always do something like this:
:e subDir/**/file<ctrl-d>
But in the docs and basically every StackOverflow/blog post I have read it seems that people use "find" the way I use "edit".
What am I missing by using the edit command instead of the find command?
Select a file or directory name and press Enter to open that file or directory. (For example :e /home/user displays the contents of that directory.) To return to the explorer window, press Ctrl-^ (usually Ctrl-6). You can also "edit" a directory to explore that directory.
TL;DR: Use for small navigation. Use with relative line numbers. h , j , k and l are the basic movement keys in Vim. They should be used instead of the usual arrow keys on the keyboard to, as discussed above, keep your fingers on the home row as much as possible.
:edit
is restricted by default to the working directory: if you need to edit a file that is not under your working directory you will have to provide its absolute path or a path relative to the working directory. Also, you need to provide the necessary globs.
:find
is superficially very similar to :edit
but the (big) difference is that it finds files in the directories specified in the path
option. path
is what makes :find
a lot more interesting than :edit
.
With set path=,,
you essentially get the same behavior as :e foo
.
With set path=**
you essentially get the same behavior as :e **/foo
except you don't have to use any glob.
With set path=.,**
you also get access to files in the same directory as the current file.
With set path=.,**,/path/to/some/central/vendor/directory
you also get access to files from that directory… and so on.
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