0

I would like to find an shortcut that does something like this:

//-------------------------
// like above and beneath
//-------------------------
Mark
  • 143,421
  • 24
  • 428
  • 436
WinnieThePooh
  • 187
  • 1
  • 10

1 Answers1

1

[ For VS Code: ]

Reworking the snippet from https://stackoverflow.com/a/63440555/836330, try this:

"Custom Comment": {
    "prefix": ["cc2"],
    "body": [
        "//-${1/./-/g}--",
        "// $1",
        "//-${1/./-/g}--"
    ]
},

custom comment demo

You can bind that to a shortcut too:

{
  "key": "ctrl+alt+r",
  "command":  "editor.action.insertSnippet",
  "args": {
    "name": "Custom Comment"
  },
  "when": "editorTextFocus"
}

If you already have the comment line and then later would like to wrap it as you showed, select the comment line first and then use this snippet:

"Custom Comment": {
    "prefix": ["cc2"],
    "body": [
      "//${TM_CURRENT_LINE/./-/g}",
      "${TM_SELECTED_TEXT}",
      "//${TM_CURRENT_LINE/./-/g}",
    ]
},

custom comment2 demo

Mark
  • 143,421
  • 24
  • 428
  • 436