vscode实现末尾加分号;然后自动换行

发布时间 2024-01-11 12:53:56作者: idonotcare

个人在敲js代码的时候会经常碰到写完一行,鼠标光标还在小括号内,然后还要按end键加分号(本人习惯写分号,就算有eslint Q-Q),然后再回车换行,感觉这样很麻烦,研究了许久得出了快捷键的设置方法:

1.先安装插件multi-command

2.文件-》首选项-》键盘快捷方式-》右上角打开键盘快捷方式(小图标)

3.在kedbindings.json的[]中输入

{
    "key": "ctrl+;",
    "command": "extension.multiCommand.execute",
    "args": {
      "sequence": [
        {
          "command": "cursorEnd"
        },
        {
          "command": "type",
          "args": {
            "text": ";"
          }
        },
        {
          "command": "editor.action.insertLineAfter"
        }
      ]
    },
    "when": "editorTextFocus"
  }

4.ctrl+;即可使用