0

I have written a VSCode snippet that makes two substitutions to the clipboard content. For instance, this snippet changes "a" characters into "x" and "e" characters into "y"

    "t2": {
        "prefix": "t2",
        "body": [
            "${CLIPBOARD/(a)|(e)/${1:?x:y}/g}"
        ],
        "description": "Makes two substitutions to the clipboard"
    },

Using this snippet, if I cut the text "This snippet changes the clipboard" and I execute the snippet, the pasted text is "This snippyt chxngys thy clipboxrd". My question is: Is it possible to create a snippet that applies three substitutions? For instance, "a" into "x", "e" into "y" and "i" into "z", obtaining "Thzs snzppyt chxngys thy clzpboxrd" in the example above.

user2178228
  • 143
  • 1
  • 1
  • 5

1 Answers1

0

Yes, you can change as many as you want. I made this snippet for another answer:

"color conditional": {
    "prefix": "_hex",
    "body": [

      "let color = '${1};",      
      "let hex = '${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}/}';" //works      
    ],
    "description": "conditional color"
  },

color conditional snippet demo

See vscode if/else conditions in user defined snippet.

for one example but in your case try:

"${CLIPBOARD/(a)|(e)|(i)/${1:+x}${2:+y}${3:+z}/g}"

instead of using the if/else conditional, you can use any number of if's.

snippet multiple replacement

Mark
  • 143,421
  • 24
  • 428
  • 436
  • Thank you very much for your answer. I tried to use succesive ifs, but I did not succeded. With your example, now I understand it. – user2178228 Oct 02 '19 at 07:02