Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple snippet prefixes in VS Code

I'm trying to write a snippet that allows me to console.log(). The following only works when I type con.

"Print to console": {
    "prefix": "con",
    "body": [
        "console.log($1);"
    ]
}

I want it to work for all the following letters as well (e.g. cons, conso, consol, console).
Is it possible or I have to duplicate the snippet as many times?
Thank you.

like image 786
isar Avatar asked Mar 07 '26 01:03

isar


1 Answers

See Is there a way to use regex expression in vscode snippet prefix? but not really a duplicate as that question asked about using regexs (which would be pretty interesting) to construct snippet prefixes.

You can put it into one snippet ala:

"Print to console": {
    "prefix": ["con", "cons", "conso", ….etc...],
    "body": [
        "console.log($1);"
    ]
}
like image 175
Mark Avatar answered Mar 08 '26 14:03

Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!