DEV Community

drake
drake

Posted on

macOS系统中 VScode中,如何实现注释后,光标自动换行

  • 1、找到快捷键的配置文件

    打开 VS Code,按 Cmd + Shift + P,搜索 "Preferences: Open Keyboard Shortcuts (JSON)" 并打开 keybindings.json。

  • 2、修改配置文件

添加如下配置

    {
        "key": "cmd+/",
        "command": "runCommands",
        "args": {
            "commands": [
                "editor.action.commentLine",
                "cursorDown"
            ]
        },
        "when": "editorTextFocus"
    }
Enter fullscreen mode Exit fullscreen mode
  • 3、保存

  • 4、配置文件修改前后对比

    修改前


// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "cmd+y",
        "command": "editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "shift+cmd+k",
        "command": "-editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    }
]
Enter fullscreen mode Exit fullscreen mode

修改后


// Place your key bindings in this file to override the defaultsauto[]
[
    {
        "key": "cmd+y",
        "command": "editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "shift+cmd+k",
        "command": "-editor.action.deleteLines",
        "when": "textInputFocus && !editorReadonly"
    },
    {
        "key": "cmd+/",
        "command": "runCommands",
        "args": {
            "commands": [
                "editor.action.commentLine",
                "cursorDown"
            ]
        },
        "when": "editorTextFocus"
    }

]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)