我阅读了 Vim 关于文件搜索
的帮助,其中解释了 *
和 **
文件搜索运算符(均在下面引用)。虽然我知道 **
仅匹配目录(默认情况下限制为 30 个目录深度),而 *
匹配所有内容(包括 /
),< strong>我认为我不明白为什么需要它们以及它们各自的用例是什么。
另外,如何只匹配列出目录中的文件? directory/*
也会匹配子目录中的文件(例如 directory/subdirectory/
),对吧?如果 *
只匹配列出的目录(没有子目录)中的文件,它们不是会更好地相互补充吗?
Vim 文档:
The usage of '*' is quite simple: It matches 0 or more characters. In a
search pattern this would be ".*". Note that the "." is not used for file
searching.
'**' is more sophisticated:
- It ONLY matches directories.
- It matches up to 30 directories deep by default, so you can use it to
search an entire directory tree
- The maximum number of levels matched can be given by appending a number
to '**'.
最佳答案
- 不,就像通配符一样,
*
不匹配/
。 - 在所有(相当少数)使用这些的情况下,vim 要么只查找文件,要么只查找目录,因此目录与您想要的文件匹配没有问题。
关于vim - Vim 文件搜索模式中 * 和 ** 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34611289/