VS Code 文件路径匹配

平时开发前端主要使用 vs code , 不少时间都用到了从文件中搜索替换功能。
当文件不少时,假如仍是从全部文件中查询,速度会很慢。
vs code 提供了根据一套语法用来匹配指定类型的文件。html

搜索框

语法

语法 描述
example 匹配全部包含 example 的文件夹和文件。
./example 在根目录下匹配 example/文件夹 。
* 匹配一个或多个字符
? 匹配一个字符
** 匹配任意多的字符,包括0个字符,如a**b 匹配 ab
{} 匹配组合。如 {**/*.html,**/*.txt}匹配全部 HTML 和 txt 文件
[] 匹配范围。如 example.[0-9] 匹配example.0, example.1, …

此外也能够在 settings.json 中配置排除文件,和搜索时排除文件:前端

// .vscode/settings.json
{
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/node_modules/**":true,
        "**/Bin": true
    },
    "search.exclude": {
        "**/node_modules": true,
        "**/static": true
    }
}

参考

  1. Search Across Filesnode

相关文章
相关标签/搜索