1

I would like to create a User Snipper in VS Code that is a combination of variables and plaint text. This can typically be achieved by combining variables and plain text with a whitespace between then. But I would like to ad a variable next to a text without a whitespace.

For Example, I would like to create the current timestamp like this: 2022-02-19T21:02:24-0530

Below is what I tried

$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATET$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND-0530

Notice the T in between $CURRENT_DATE & $CURRENT_HOUR

OUTPUT:

2022-02-CURRENT_DATET21:06:12-0530

Gangula
  • 5,193
  • 4
  • 30
  • 59

2 Answers2

1

You can add $ symbol before the plain-text you want to add.

In this case, you need at add $T instead of T

$CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE$T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND-0530

Note that $T will get considered as a placeholder, and it will be the last item selected while tabbing through the inserted snippet.

Gangula
  • 5,193
  • 4
  • 30
  • 59
0

@Gangula's answer sparked a thought that lead me to an completely automated solution.

Combining with the variable transform examples found in the official doc, you can do:

$CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE/(.*)/$1T/}$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND-0530

In short, I am regex selecting the date variable and replacing it with itself + 'T'.

Marquee
  • 1,776
  • 20
  • 21