在 visual studio 中是否有注释后跟一行连字符的快捷方式?

Is there a shortcut for a comment followed by a line of hyphens in visual studio?

我想找到一个快捷方式来做这样的事情:

//-------------------------
// like above and beneath
//-------------------------

[对于 VS 代码:]

修改 中的片段,试试这个:

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

您也可以将其绑定到快捷方式:

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

如果您已经有了注释行,稍后又想按照您显示的方式将其包装起来,请先 select 注释行,然后使用此代码段:

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