Search code examples
visual-studio-codecomments

Make specific Style of comments


In VScode is there is a shortcut to make a comment/header like this

/*------------------------------------------------------------

site-header

------------------------------------------------------------*/

How can I do that? If I need some kind of extension do let me know.


Solution

  • Use a custom snippet for this. Then you can setup a keybinding for the snippet.

    Here's an example keybinding for such a snippet:

    {
      "key": "cmd+k 1",
      "command": "editor.action.insertSnippet",
      "when": "editorTextFocus",
      "args": {
        "snippet": "/*------------------------------------------------------------\n${TM_FILENAME}\n------------------------------------------------------------*/"
      }
    }
    

    If you want the header to always be inserted at the top of the file, you need to create a simple extension