I am looking for a method where I place cursors at different positions, and then place numbers at those positions in hex form such that numbers are ranging from 8 to 10, in two digit format, as following:
case_
case_
case_
case_
case_
case_
case_
case_
case_
into :
case_08
case_09
case_0A
case_0B
case_0C
case_0D
case_0E
case_0F
case_10
Anyone knows any key(combination) to do that?
CodePudding user response:
If you want the hex numbers to start over at 08
no matter how many you select initially, use this replace
:
// with this version you just select the whole block and the numbers will run from 08 - 10 and start over at 08, see demo
{
"key": "alt n",
"command": "findInCurrentFile",
"args": {
"find": "(?<=case_)", // added this to previous version
"replace": [
"$${",
"let result = ${matchIndex} % 9 8;", // added the '% 9' to wrap at 08
"return result.toString(16).padStart(2,'0').toUpperCase();",
"}$$"
],
"isRegex": true,
"restrictFind": "selections" // added this, find just in selections
},
}