navigating filesystem in vim -> :find vs. :edit

做~自己de王妃 提交于 2020-05-27 03:55:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!