Visual Studio 代码 Find/replace - 用名称保存
Visual Studio Code Find/replace - save with name
我经常发现在 visual studio 代码中我需要一些自定义正则表达式。
每次我使用 Whosebug 搜索来查找相同的正则表达式,而不是尝试一次又一次地重写它。现在我有一个单独的文本注释仅用于此目的,其中包含我的 find/replace 正则表达式值。
例如
是否有自定义智能插件或选项允许我添加查找/替换并给它们命名并直接在 Visual Studio 代码中保存它们(类似于 ultra edit)?
如果有一种方法可以在 Visual Studio 而不是代码中执行相同的操作,我也很好 - 我只需要能够快速查找替换。
至少有三个扩展程序可以帮助您:
Find and Transform - 这是我写的
它们允许您存储和 运行(单独或全部保存)正则表达式的查找和替换列表。
来自查找和替换的示例设置(在 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.json
中):
{
"key": "alt+y",
"command": "findInCurrentFile", // note no setting command here
"args": {
"find": "^([ \t]*const\s*)(\w*)", // note the double escaping
"replace": "\U", // capitalize the word following "const"
"isRegex": true,
"restrictFind": "selections" // find only in selections
}
}
因此您可以将 find/replace 或跨文件搜索保存为命名设置或键绑定。
我经常发现在 visual studio 代码中我需要一些自定义正则表达式。
每次我使用 Whosebug 搜索来查找相同的正则表达式,而不是尝试一次又一次地重写它。现在我有一个单独的文本注释仅用于此目的,其中包含我的 find/replace 正则表达式值。
例如
是否有自定义智能插件或选项允许我添加查找/替换并给它们命名并直接在 Visual Studio 代码中保存它们(类似于 ultra edit)?
如果有一种方法可以在 Visual Studio 而不是代码中执行相同的操作,我也很好 - 我只需要能够快速查找替换。
至少有三个扩展程序可以帮助您:
Find and Transform - 这是我写的
它们允许您存储和 运行(单独或全部保存)正则表达式的查找和替换列表。
来自查找和替换的示例设置(在 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.json
中):
{
"key": "alt+y",
"command": "findInCurrentFile", // note no setting command here
"args": {
"find": "^([ \t]*const\s*)(\w*)", // note the double escaping
"replace": "\U", // capitalize the word following "const"
"isRegex": true,
"restrictFind": "selections" // find only in selections
}
}
因此您可以将 find/replace 或跨文件搜索保存为命名设置或键绑定。