i have many pieces of code same for example like this
alt="Greece"
alt="Greece"
alt="Greece"
alt="Greece"
Can i somehow modify it to this? Is there any kind of function like in Excel or something like that please? Imagination write it manualy each is horrible
alt="Greece 1"
alt="Greece 2"
alt="Greece 3"
...
alt="Greece 200"
2
Answers
You can use the extension Regex Text Generator
Greece
Ctrl+D
multiple timesCtrl+Shift+L
to select allShift+Alt+Click
to create multiple cursorsRightArrow
to get all cursors after the wordGreece
Original Text Regex
use:.*
Generator Regex
use:{{=i+1}}
(watch the space as first char)Esc
to cancel andEnter
to acceptYou can use any calculation based on
i
you want and you can also match number in the selected text and use that in the calculationN[...]
.You can also add the word Greece by using
Greece {{=i+1}}
You have a couple of options. First, using the extension, Find and Transform (disclaimer, I wrote that extension, this is very easy. Make this keybinding in your
keybindings.json
(after installing the extension):Actually you can make it even easier if you first select what you want to modify (see the demo below). Then use this simple keybinding:
Another option – not quite as easy
Snippets have a variable
$CURSOR_NUMBER
which is useful here.Make this keybinding:
alt="Greece"
Demo of this method:
So this second method is more steps but doesn’t require an extension.