Open wibotwi opened 3 years ago
uff, VS Code is so stupid :( It does not do line comment if multiple lines are selected :( See https://github.com/microsoft/vscode/issues/35464
I was a very happy when I found the IntelliJ IDEA Keybindings (as a former IDEA user)
The only thing anoing was the commmentLine didn't move cursor down! Was happy to find the fix myself when I added this to my keybindings.json:
{
"key": "ctrl+Numpad_Divide",
"command": "runCommands",
"args": {
"commands": ["editor.action.commentLine", "cursorDown"]
},
"when": "editorTextFocus && !editorReadonly"
},
Thanks @stenaksel. This was driving me crazy.
"ctrl+Numpad_Divide"
did not work for me. I had to use "ctrl+[Slash]"
@wibotwi @stenaksel @close2 I add "cursorDown" for this. Please check v1.5.11
@kasecato is there any way to disable that feature after updating to v1.5.11? I want to keep the cursor on the same line after applying a one-line-comment
@kasecato is there any way to disable that feature after updating to v1.5.11? I want to keep the cursor on the same line after applying a one-line-comment
I also would like to disable this feature. While I can see it might be useful when commenting out a line of code, it's pretty annoying when adding a new comment via Cmd+/
to then have to go back up a line to write the comment. I suppose that I could just write the comment and then Cmd+/
to turn it into a proper comment, but that's not how I work and I'd rather disable it then have to relearn the muscle memory.
it's pretty annoying when adding a new comment via Cmd+/
just checked IDEA, it actually doesn't move to new line if you hit Cmd+/ on empty line IDEA is quite smart :)
@dspigarelli I found a workaround, just in case anybody else is interested.
Add this entry to your keybindings.json
to overwrite the behavior introduced by the extension:
{
"key": "ctrl+/",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
}
Thanks for the suggestion, @ivan-nosar. However, it didn't seem to work for me when I added it to ~/Library/Application Support/Code/User/keybindings.json
. For now I've downgraded to 1.5.10 and will probably stay there unless this is reversed or some config put in place to disable the behavior.
Reverted on v1.5.12.
@kasecato I don't really understand why you reverted this commit. The correct behavior is to move to the next line.
If some users don't like intellij keybindings, they should either not use intellij keybindings or customize their bindings (as they would need to do in intellij as well).
I would imagine that commenting an empty line happens far less often than commenting a line of code.
@close2 It seems like the functionality as implemented in this PR doesn't behave exactly like intellij. If this change behaved like intellij for commenting both an empty line (i.e. stay on line) and an existing line of code (i.e. skip down a line), I don't think there would be any issue with it.
To fully support this feature, we need to have LSPs support per-language Statements related with https://github.com/kasecato/vscode-intellij-idea-keybindings/issues/175#issuecomment-1950998550
Found this thread: https://www.reddit.com/r/vscode/comments/7nlp9k/when_commenting_a_line_move_the_cursor_to_the/ They suggested:
Can we add this to vscode-intellij-idea-keybindings ?