Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commenting out code does not work properly in VS code

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.

like image 584
hello Avatar asked Mar 05 '26 09:03

hello


2 Answers

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.

like image 51
subodhkalika Avatar answered Mar 07 '26 13:03

subodhkalika


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

like image 31
tcf01 Avatar answered Mar 07 '26 11:03

tcf01