Programming

Sublime Text 3에서 줄을 주석 처리하는 키보드 단축키

procodes 2020. 6. 2. 21:56
반응형

Sublime Text 3에서 줄을 주석 처리하는 키보드 단축키


Sublime Text 2에서 Ctrl+ /Ctrl+ Shift+로 한 줄 또는 여러 줄을 주석 처리 할 수있었습니다 /. 메뉴에 Edit > Comment따르면 이러한 단축키는 유효하지만 Sublime Text 3 (빌드 3047)에서는 더 이상 작동하지 않는 것 같습니다. 누구든지 Linux 및 MacOS에 적합한 기본 키보드 단축키를 알고 있습니까? 아니면 버그입니까?


버그 인 것 같습니다 : http://www.sublimetext.com/forum/viewtopic.php?f=3&t=11157&start=0

해결 방법으로 Preferences-> 로 이동하여 Key Bindings - User다음 키 바인딩을 추가하십시오 (Linux를 사용하는 경우).

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

업데이트 : 이것은 Windows 8에서도 작동합니다 (@Sosi의 의견 참조)


환경 설정 / 키 바인딩-사용자에 다음 행을 추가 할 수 있습니다.

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

이것은 "ctrl"을 "control"로 바꾸고 "/"를 "keypad_divide"로 바꾸어 문제를 정리 한 방법입니다.


이것은 키보드 국제화 문제입니다.

Sublime Text가 만들어지는 호주에서 사용되는 표준 US QWERTY 키보드에서 다음을 /쉽게 사용할 수 있습니다.미국 쿼티 키보드

다른 키보드는 그렇지 않습니다. 독일어 QWERTZ 키보드를 예로 들어 보겠습니다. 히트 한 가지 요구 사항 SHIFT+는 7를 얻을 수 있습니다 /. 이러한 키보드에서는 주석 처리가 제대로 작동하지 않습니다.독일어 QWERTZ 키보드

사용자 키 바인딩을 아래에 나열된 키 바인딩으로 변경하면 독일어 QWERTZ 키보드에서 작동합니다.

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

여전히 다른 키보드 레이아웃으로 문제가 발생하면 이에 따라 키 바인딩을 변경하십시오.


U는 다음을 통해이 버그를 해결할 수 있습니다.

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

it allow to comment with CTRL+/ and CTRL+SHIFT+/ and u can use / on keypad =)


This worked for me.

cmd + /

I'm on Mac OS X El Capitan. Sublime Text 3 (stable build 3114).


I'm under Linux too. For me, it only works when I press CTRL+SHIFT+/, and it's like a single comment, not a block comment. The reason is to acceed the / character, I have to press SHIFT, if I do not, sublime text detects that I pressed CTRL + :.

Here it is my solution to get back normal preferences. Write in Key Bindings - User :

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


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.

키보드 설정

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


It's simpler than you think press cmd + / in mac.


For Brazilian ABNT Keyboards you do Ctrl + ; to comment and repeat it to remove the comment.


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.


Make sure the file is a recognized type. I had a yaml file open (without the .yaml file extension) and Sublime Text recognized it as Plain Text. Plain Text has no comment method. Switching the file type to YAML made the comment shortcut work.


On MAC instead of shift use ALT like this CMD + ALT + /


Had the same issue. Check with sublime.log_input(True) command on the console to see what keys are being detected with the CTRL+/ and SHIFT+CTRL+/ shorcuts. Then replace the shortcuts with those. (Changing / for keypad_divide worked for me)


For me, on Mac OS Sierra :

{ "keys": ["super+forward_slash"], "command": "toggle_comment", "args": { "block": true } }, { "keys": ["super+alt+:"], "command": "toggle_comment", "args": { "block": false } },

Sublime 3 for Windows:

Add comment tags -> CTRL + SHIFT + ;
The whole line becomes a comment line -> CTRL + ;


In case anyone has had further issues with Sublime 3 on Windows 7, the above suggestions all did not work for me. However, when I 1 - reran the app as administrator and 2 - highlighted, and chose Edit -> Comment -> toggle comment, afterwards I was able to use a user preferences set keybinding to toggle comments. I don't really have an explanation for why it worked, except that it did.


Open sublime Text 3 and go to Preferences menu and the click on Key Bindings then paste this code to make a comment shortcut with CTRL+D.

[{ "keys": ["ctrl+d"],"command": "toggle_comment", "args": {"block": false}},]

then save it. now you can use shortcut.


On windows, use Ctrl + Shift + ?. You will be able to comment the HTML.


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.


If the shortcut ctrl+?, ctrl+shift+? or ctrl+/ is not working, try switching to another, like ctrl+1, ctrl+shift+1, it worked for me.

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


In Windows use ctrl + shift + : to comment for Python.


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+ /결과는 선택 시작부터 끝까지 전체적인 주석입니다.

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

파티에 늦었을 수도 있지만 빌드 3176에서 버그가 수정 된 것으로 보입니다. 방금 Ctrl + T를 사용했으며 CSS 파일 (Kubuntu 18.10)에서 작동했습니다.


Ctrl + /현재 줄을 주석 처리하려면 주석을 누르십시오 . 또한 커서가 한 줄 아래로 이동하기를 원하므로 여러 줄을 쉽게 주석 해제 할 수 있습니다. "Chain of Command"플러그인을 설치하면 다음 두 작업을 결합 할 수 있습니다.

[
    { 
        "keys": ["ctrl+keypad_divide"], 
        "command": "chain",
        "args": {
            "commands": [
                ["toggle_comment", { "block": false }],
                ["move", {"by": "lines", "forward": true}]
            ]
        }
    }
]

참고 URL : https://stackoverflow.com/questions/17742781/keyboard-shortcut-to-comment-lines-in-sublime-text-3

반응형