Skip to content

VS Code JSX Block Comment Setup #40

@AverTry

Description

@AverTry

Sorry did not know where to put this, but I wanted to share this in case anyone else needed it.

vsCode keybindings, to change as needed.
For commenting inside <style jsx> tags.
vscode inside jsx does {/* Your Comment or code /}
The code below, will do CSS comments /
Your comment or code */

Thanks again for solid-styled, as I use it all the time.

// Place your key bindings in this file to override the defaults
[
  {
    // Toggle for single line at cursor - no selection needed.
    "key": "ctrl+shift+/",
    "command": "runCommands",
    "args": {
      "commands": [
        "cursorEnd", // so cursor stays on same line
        "cursorHomeSelect",
        {
          "command": "editor.action.insertSnippet",
          "args": {
            // I failed because I used 3 not 4 - crazy regex groups.
            "snippet": "${TM_SELECTED_TEXT/(\\/\\* )(.+)( \\*\\/)|(.*)/$2${4:+/* }$4${4:+ */}/}"
          }
        }
      ]
    },
    // "when": "editorLangId == javascript || editorLangId == typescript"
    "when": "resourceExtname =~ /\\.(js|ts|r)(?!on)/"
  },
  {
    // Toggle for multi-line, pre-selected block /* ... */
    "key": "ctrl+shift+oem_7",
    "command": "editor.action.insertSnippet",
    "args": {
      "snippet": "${TM_SELECTED_TEXT/(\\/\\*)([\\s\\S]*?)(\\*\\/)|([\\s\\S]+)/$2${4:+/* }$4${4:+ */}/}"
    },
    "when": "resourceExtname =~ /\\.(js|ts|r)(?!on)/"
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions