Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Commenting to move to next line as in Idea #233

Open
wibotwi opened this issue Jul 9, 2021 · 13 comments
Open

Commenting to move to next line as in Idea #233

wibotwi opened this issue Jul 9, 2021 · 13 comments

Comments

@wibotwi
Copy link

wibotwi commented Jul 9, 2021

Found this thread: https://www.reddit.com/r/vscode/comments/7nlp9k/when_commenting_a_line_move_the_cursor_to_the/
They suggested:

You can use the geddski.macros extension to bind the two commands to a key combo:

Add macro to settings.json -- "macros": { "commentLine": ["editor.action.commentLine","cursorDown"] }

Map a key in keybindings.json (use you own favorite key combo) -- { "key": "ctrl+/", "command": "macros.commentLine", "when": "editorTextFocus && !editorReadonly" }

Can we add this to vscode-intellij-idea-keybindings ?

@wibotwi
Copy link
Author

wibotwi commented Jul 9, 2021

uff, VS Code is so stupid :(
It does not do line comment if multiple lines are selected :(
See microsoft/vscode#35464

@kasecato kasecato self-assigned this Oct 29, 2021
@stenaksel
Copy link

stenaksel commented Mar 31, 2023

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"
  },

@close2
Copy link

close2 commented Sep 11, 2023

Thanks @stenaksel. This was driving me crazy.

"ctrl+Numpad_Divide" did not work for me. I had to use "ctrl+[Slash]"

@kasecato kasecato added this to the v1.5.11 milestone Oct 8, 2023
kasecato added a commit that referenced this issue Oct 8, 2023
Fixed #233 that Commenting to move to next line as in Idea
@kasecato kasecato reopened this Oct 8, 2023
@kasecato
Copy link
Owner

kasecato commented Oct 8, 2023

@wibotwi @stenaksel @close2 I add "cursorDown" for this. Please check v1.5.11

@ivan-nosar
Copy link

@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

@dspigarelli
Copy link

@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.

@wibotwi
Copy link
Author

wibotwi commented Oct 17, 2023

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 :)

@ivan-nosar
Copy link

@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"
}

@dspigarelli
Copy link

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.

kasecato added a commit that referenced this issue Oct 19, 2023
@kasecato kasecato mentioned this issue Oct 19, 2023
@kasecato
Copy link
Owner

kasecato commented Oct 20, 2023

Reverted on v1.5.12.

@kasecato kasecato modified the milestones: v1.5.11, v1.5.12 Oct 20, 2023
@close2
Copy link

close2 commented Oct 25, 2023

@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.

@dspigarelli
Copy link

@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.

@kasecato
Copy link
Owner

To fully support this feature, we need to have LSPs support per-language Statements
related with #175 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants