Home > Software engineering >  Is it possible to highlight vscode snippets variables?
Is it possible to highlight vscode snippets variables?

Time:01-03

I have written a vscode snippet for a python function definition with a block comment. However, block comments are not always needed.

I'd like to be able to traverse to the inside of the block comment and then to the highlighted block comment for fast deletion if neccesary.

"def": {
        "scope": "python",
        "prefix": "def func",
        "body": [
            "def $1 ():",
            "\t$BLOCK_COMMENT_START $2 $BLOCK_COMMENT_END",
            "\t$0"
        ],
        "description": "Python function"  

Desired output

enter image description here

CodePudding user response:

Try wrapping that whole block comment in a tabstop:


"def": {
  "scope": "python",
  "prefix": "def func",
  "body": [
      "def $1 ():",
      "\t${3:$BLOCK_COMMENT_START $2 $BLOCK_COMMENT_END}",
      "\t$0"
  ],
  "description": "Python function" 
}

\t${3:$BLOCK_COMMENT_START $2 $BLOCK_COMMENT_END} or
"${3:\t$BLOCK_COMMENT_START $2 $BLOCK_COMMENT_END}" with the \t included in the selection.

Then after $2, and tab all of the block comment start and end will be selected and you can delete it if you wish.

block comment snippet wrap

  • Related