至少有三个扩展可以帮助您:
查找和转换——我写的
替换规则
替换
它们允许您存储和运行(单个或全部保存)正则表达式的查找和替换列表。
查找和替换中的示例设置(在 中settings.json):
"findInCurrentFile": { 
  "addClassToElement": {
    "title": "Add Class to Html Element",   // will appear in the Command Palette
    "find": ">",
    "replace": " class=\"@\">",
    "restrictFind": "selections",
    "cursorMoveSelect": "@"   // after the replacement, move to and select this text
  }
}
keybindings.jsonFind and Replace中的一个 keybinding(in) 示例:
{
  "key": "alt+y",
  "command": "findInCurrentFile",     // note no setting command here
  "args": {
    
    "find": "^([ \\t]*const\\s*)(\\w*)",   // note the double escaping
    
    "replace": "$1\\U$2",                  // capitalize the word following "const"
    "isRegex": true,
    
    "restrictFind": "selections"           // find only in selections
  }
}
因此,您可以将查找/替换或跨文件搜索保存为命名设置或键绑定。