Keyboard shortcut to comment lines in Sublime Text 3

后端 未结 26 2537
深忆病人
深忆病人 2020-12-02 04:42

In Sublime Text 2 it was possible to comment out a line or a block of lines with Ctrl+/ and Ctrl+Shift+/. According t

相关标签:
26条回答
  • 2020-12-02 04:43

    This worked just fine for me on Win 10:

        [{ "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
    { "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } }
    ]
    

    note that "[ ]" are nesassary and it will give you an error if you miss them.

    0 讨论(0)
  • 2020-12-02 04:44

    On OSX Yosemite, I fixed this by going System Preferences, Keyboard, then Shortcuts. Under App Shortcuts, disable Show Help menu which was bound to CMD+SHIFT+7.

    keyboard settings

    My keyboard layout is Norwegian, with English as the OS language.

    0 讨论(0)
  • 2020-12-02 04:46

    In my notebook keyboard, a ABNT 2, I can use the CTRL+; shortcut as the default comment action for blocks and lines. The same shortcut to uncomment.

    0 讨论(0)
  • 2020-12-02 04:47

    On my mac the shortcut is ⌘cmd + / which makes multi line comment but as single lines:

    // if ($username && $password) {
    //  echo "You are good to go";
    // } else {
    //  echo "Fields cannot be blank";
    // }
    

    OR

    ⌥ alt + ⌘cmd + / and it's result is overall comment, from beggining of the selection to the end.

    /*
    if ($username && $password) {
        echo "You are good to go";
    } else {
        echo "Fields cannot be blank";
    }
    */
    
    0 讨论(0)
  • 2020-12-02 04:48

    Use Ctrl + / for single line comment and
    Ctrl + Alt + / for block or multiline comments.

    0 讨论(0)
  • 2020-12-02 04:49

    It seems a bug: http://www.sublimetext.com/forum/viewtopic.php?f=3&t=11157&start=0

    As a workaround, go to Preferences->Key Bindings - User and add these keybindings (if you're using Linux):

    { "keys": ["ctrl+7"], "command": "toggle_comment", "args": { "block": false } },
    { "keys": ["ctrl+shift+7"], "command": "toggle_comment", "args": { "block": true } }
    

    Update: This also works on Windows 8 (see @Sosi's comment)

    0 讨论(0)
提交回复
热议问题