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

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay