Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio comment and uncomment with a single simple keyboard shortcut

I want to know if it is possible to comment and uncomment text blocks in Visual Studio with a single command.

I'm used to just press Ctrl + / to toggle between comment and uncomment text blocks, because I've been using IntelliJ IDEA.

But in Visual Studio you have to press:
Ctrl + k + c to comment code, and
Ctrl + k + u to uncomment code.

Is there any way to comment / uncomment your code in Visual Studio with a single command just like in IntelliJ IDEA?

like image 282
GoldNova Avatar asked Nov 16 '25 23:11

GoldNova


2 Answers

Actually yes, there is a way.

  • Go to Tools -> Options... in the menu
  • Select Environment -> Keyboard from the options list
  • Find / Show Edit.ToggleLineComment in the keyboard commands list

Options — Environment -> Keyboard — Edit.ToggleLineComment

Here you can setup how to comment / uncomment a single or even multiple lines with a single keyboard shortcut.

like image 124
XtremeBaumer Avatar answered Nov 18 '25 19:11

XtremeBaumer


You can actually follow this path Tools -> Options -> Environment -> Keyboard and change the drop-down selection on your top right to Visual Studio Code. This will allow you to use the Visual Studio Code keyboard bindings such as CTRL+/ to comment/uncomment.

like image 26
createandlove Avatar answered Nov 18 '25 21:11

createandlove



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!