问题
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?
回答1:
: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.
来源:https://stackoverflow.com/questions/32898923/navigating-filesystem-in-vim-find-vs-edit