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

相關文章
相關標籤/搜索