Reputation: 17156
There were Ctrl+E+C (comment) and Ctrl+E+U (uncomment) in older versions, or Ctrl+K+C and Ctrl+K+U.
But in Visual Studio 2012, I can't see key shortcuts:
How can I enable those shortcuts?
Upvotes: 143
Views: 270543
Reputation: 1076
Shift + Alt + A.
The command palette is great for finding shortcut keys.
Upvotes: -1
Reputation: 1
"commentLine" is the name of function you are looking for. This function comments and uncomments with the same keybinding.
Upvotes: 0
Reputation: 177
Use the keys Ctrl + K,C to comment out the line and Ctrl + K, U to uncomment the line.
Upvotes: 13
Reputation: 18980
You can also add the toolbar in Visual Studio to have the buttons available.
Menu View → Toolbars → Text Editor
Upvotes: 19
Reputation: 12546
From your screenshot it appears you have ReSharper installed.
Depending on the key binding options you chose when you installed it, some of your standard shortcuts may now be redirected to ReSharper commands. It's worth checking, for example Ctrl+E, C is used by ReSharper for the code cleanup dialog.
Upvotes: 8
Reputation: 354999
Keyboard accelerators are configurable. You can find out which keyboard accelerators are bound to a command in menu Tools → Options on the Environment → Keyboard page.
These commands are named Edit.CommentSelection and Edit.UncommentSelection.
(With my settings, these are bound to Ctrl + K, Ctrl + C and Ctrl + K, Ctrl + U. I would guess that these are the defaults, at least in the C++ defaults, but I don't know for sure. The best way to find out is to check your settings.)
Upvotes: 169
Reputation: 1290
I went to menu: Tools → Options.
Environment → Keyboard.
Show command containing and searched: comment
I changed Edit.CommentSelection and assigned Ctrl+/ for commenting.
And I left Ctrl+K then U for the Edit.UncommentSelection.
These could be tweaked to the user's preference as to what key they would prefer for commenting/uncommenting.
Upvotes: 1
Reputation: 140
This is how I did it,
Menu Tools → Options on the Environment → Keyboard window
One can alter the default shortcuts following the below steps
Upvotes: 2