I have a document with contains ## for list sign.
I want to replace ## with order numbers.
first matched ## -> to 1.
second matched ## -> 2.
.... 3.
.... 4.
Is this possible to do in an editor, like VS Code etc.
I have a document with contains ## for list sign.
I want to replace ## with order numbers.
first matched ## -> to 1.
second matched ## -> 2.
.... 3.
.... 4.
Is this possible to do in an editor, like VS Code etc.
2
Answers
You can use the extension Regex Text Generator
The generate expression you want is:
{{=i+1}}
You can do this without an extension by first selecting all the
##
‘s you want to change. One way is by a Find:##
and then Alt+Enter to select all those matches.Then run this keybinding:
To combine the find, select all and replace in one step you can use the extension Find and Transform, which I wrote. Here is a sample keybinding that will do what you want (in your
keybindings.json
):${matchNumber}
is 1-based,${matchIndex}
is 0-based.