Home > OS >  Emmet Snippet to Write Many Numbered Variables
Emmet Snippet to Write Many Numbered Variables

Time:03-24

I'm writing some JS that requires a bunch of similar variables, numbered. I can do this just fine with multiple cursors etc, but since I'm using Emmet so much I wondered if there was a simple one line way of writing a list like:

let element1, element2, element3 ...

Is there a reason?

CodePudding user response:

If you don't get an emmet answer, an extension I wrote, increment the match number

CodePudding user response:

If you have to regularly have to apply numbers at the current cursor positions you can use the extension Regex Text Generator with a predefined setting.

"regexTextGen.predefined": {
    "sequantial numbers" : {
      "originalTextRegex": "(.*)",
      "generatorRegex": "{{=i 1}}"
    }
  }
  • Place the cursors at the location needed (select all element and RightArrow)
  • execute command: Generate text based on Regular Expression
  • choose the sequantial numbers option
  • Enter and possibly adjust the offset

If you don't define a preset you can type the expressions yourself.

  • Related