12

I used to able to comment or uncomment multiple lines of code by pressing ctrl+/

# x = 10 # print(x) 

But now I press ctrl+/, it becomes the following:

... 

I tried to search for solution online, and I believe it is because the Windows shortcut somehow overwrite the shortcut in VS code. But I cannot find a solution.

I tried:

1.Reset the shortcut

2.Reinstall VS code

They don't work. Any help is appreciated.

10 Answers 10

22

First of all see which keyboard layout you are using on your System. Change the Keyboard layout to US-Keyboard if US keyboard is not selected.

If it is US keyboard then,

The shortcut key might have changed.

You can edit your preferences on VS code.

  1. Goto File > Preferences > Keyboard Shortcuts

  2. Search for Toggle Line Comments.

  3. Click on edit icon and press your desired shortcut key

It could also be caused due to the same key bindings for shortcuts.The Keyboard Shortcuts editor has a context menu command Show Same Keybindings, which will filter the keybindings based on a keyboard shortcut to display conflicts. To view same key bindings follow the above steps till Step 3. Now right click on the Toggle Line commands and click Show same key bindings.

Sign up to request clarification or add additional context in comments.

3 Comments

Not working in Linux Mint
@thinkerBOB conflict in key binding is possible. remove them
Had this isue recently. Was due to Copilot rebinding ctrl / to accept suggestion at cursor.
6

I encounter this problem before. You should press shift key to switch back to type English and try again.

2 Comments

I lost 45 mins of time on this until I saw your comment. haha
don't know why, but it works for me.
3

As already said, you might just have another keyboard layout. Check the menu to see which shortcut you need to press. For example, Toggle line comment is Ctrl+# here:

enter image description here

(By mistake, I had thought at first that I can handle the shortcuts only if I stick to the US-ENG keyboard layout to have Ctrl+/ back. Not needed; check your menu in the other layout.)

1 Comment

I think this is a helpful answer to check what is happening. It complements the accepted answer.
1

I also had the same issue on my mac and the solution was that I was missing the language support. I was working with terraform and once I installed the corresponding plugin, it worked like as it should, plain normal.

So I guess the reasons could be many, check shortcuts, check language support, etc.

Comments

0

go to keyboard short cuts search for toggle line comment

check when expression in when column

right click on the when expression and edit and paste "editorTextFocus && !editorReadonly"

Comments

0

Open Settings, find keyboard on Application/Keyboard change Keyboard: Dispatch code to keyCode.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
0

I had this issue and because I installed Notepad++ keymap extension a while ago and forgot about it. Disabling the Notepad++ keymap extension and restarting VS Code solved the problem.

Comments

0

I had the same problem but it was not caused by the keyboard layout.

I verified this by selecting Edit > Toggle Line Comment & Edit Toggle Block comment from the UI, and nothing was happening.

For me it turned out that i had somehow disabled built in php support (probably to use some extension).

so the solution was to go to Extensions. Search for "@builtin php" Enable PHP Language Features and PHP Language Basics.

Comments

0

vscode screenshot

For me source language change to english did the trick.

Comments

-2

It depends on what language you are programming. But if you want to type # character you can hold down shift key and press number 3 on your keyboard.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.