我想知道是否有一种方法可以在visual studio代码的替换输入字段中使用当前找到的索引。
示例文本
<NotationType />
<NotationType />
<NotationType />查找<NotationType并用<NotationType id="q-CURRENTINDEX"替换所有出现的事件
<NotationType id="q-0" />
<NotationType id="q-1" />
<NotationType id="q-2" />这有可能吗?
发布于 2021-08-12 04:29:27
我编写了一个扩展来处理类似的情况,您希望访问诸如匹配索引、行号、路径变量、剪贴板、条件替换(就像片段可以做的那样)等变量:查找和变换。
您的情况相对简单,使用这个键绑定(或者它可能是一个设置):
{
"key": "alt+y", // whatever keybinding you want
"command": "findInCurrentFile",
"args": {
"find": "(NotationType)",
"replace": "$1 id=\"q-${matchIndex}\"",
// "restrictFind": "selections", // if you need it
"isRegex": true
}
}

https://stackoverflow.com/questions/64207189
复制相似问题