How to uncomment multiple lines of code in Visual Studio - visual-studio

I did a ctrl K + ctrl C (adds // to a line) on a lot of lines of code that I need uncommented. What is the quick key method to uncomment code in Visual studio?

Ctrl+K, Ctrl+U removes the // comments

I believe it is Ctrl + K, Ctrl + U.

Ctrl + K, Ctrl + U.
There is also a button for it on the Standard toolbar.

ctrl + /
can be used for adding and removing comments.

Try + U or click the little icon on the toolbar.

If you're using Resharper, there is a much nicer alternative:
just right Alt + / for both
By using this single shortcut, you can simply toggle between commenting/uncommenting code, without having to remember/switch between two shortcuts for each.

Ctrl + K + C (to comment) and Ctrl + k + U (to uncomment the code)
Or
or use Ctrl + / (for the same)

Qwerty: Ctrl + /
Azerty: Ctrl + :

Just wanted to add, that in the latest version of VS, ctrl + u makes it caps. They instead made it a toggle command, so it is actually just ctrl + k again to make it uncommented.

I have the german keyboardlayout.
VSCode-x64-1.52.1
To leave a comment:
You have to highlight the code, then push
Ctrl + #
or
Ctrl+K, stay at Ctrl and push C
to commen out:
Ctrl + #, it toggles on/off the comment
or
Ctrl + K, stay at Ctrl and push U

Mine was a bit different. It is ctrl-shift-C to comment and ctrl-shift-alt-C to uncomment.
I am using Visual Studio Community 2017.

Ctrl + Q alternates between comment and uncomment.
Unfortunately Ctrl K Ctrl U does not work in few environments, rather it adds instead of removing. My case on windows, using composer file I faced Ctrl K Ctrl U not working.
I m using VS Code, ver 1.36.1
links to all keys short cuts: https://code.visualstudio.com/docs/getstarted/keybindings

In Visual C++ 2019 Ctrl + Shift + / both comments and uncomments.

Related

Whats the visual studio equivalent to eclipse alt + arrow Left

From Eclipse i'm confortable with
F3 to enter a method and ALT + <-
In visual studio (2010) its F12 to enter the method, but how do i get back to the call, where i jumped in?
You can use Shift + F12 to list all references, and the original method will be listed.
Ctrl + - will navigate backward, whilst Ctrl + Shift + - will navigate forward (in the context of where you were working in your code).
Ctrl + , will allow you to search for a method to navigate to.
In my VS Code V 1.20.1 the shortcut is:
Ctrl + Alt + - for backward.
For going forward is Ctrl + Shift + -.
We can change these shortcuts just like in Eclipse by selecting the menu File -> Preferences -> Keyboard shortcuts, and type on the search field for Go Back or Go Forward.
To do this on MacOS VS Code
^+- to go backward.
^ + shift + - to go forward.
Note that^ is control on your keyboard.
Full list of other mac keyboard shortcuts here: https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf

how to enable the comment buttons in visual studio

I am using visual studio.
In the tool bar,"comment" and "uncomment" buttons are disabled.
and If I use Ctrl + K and Ctrl + C` also ,I am not able to comment the code.
how to solve this?
It's CTRL + K + C not CTRL + K and CTRL + C :)
You need to select some text with your mouse to use those buttons. You also can't be in a state where editing is locked (such as while debugging).

Visual Studio 2010 Keyboard Shortcut Chords

I started out with VB6 default shortcuts where Ctrl + R brings up the Solution Explorer window.
Now when I hit Ctrl + R I see a status message saying that VS is waiting for me to hit the next sequence in the chord, suggesting to me that I have shortcuts that begin with Ctrl + R but require another keystroke.
This suggests to me that having one or more shortcut sequences that begin with Ctrl + Rinvalidates the Ctrl + R shortcut, which I can understand, but the question is, how do I find what those command are so I can assign a different sequence to them?
Also, shouldn't VS warn me when assigning the first chord shorcut that begins with Ctrl + R that this will invalidate my Ctrl + R shortcut or, it should clear it out so Ctrl + R is no longer a shortcut for the Solution Explorer window.
Anyway, I guess the question is how do I locate the commands that begin with Ctrl + R so I can change them so they dont collide with my Solution Explorer shortcut Ctrl + R?
In VS 2010, Tools | Options | Environment | Keyboard gets you to the right place. Now, put the cursor in Press shortcut keys, and press the keys you are interested in (so Ctrl + R). The Shortcut currently used by dropdown will then show you all the shortcuts that currently involve the keys you have pressed.
I agree it would be a 'nice to have' for VS to warn about overlapping shortcuts, but note that different shortcuts can have different scopes of effect (in the Use new shortcut in dropdown), so this might not be as easy as it sounds.
The keybindings poster from MSDN might be helpful. It looks Ctrl + R behaves differently depending on if you are debugging or not.
Have a look at IntelliCommand Plugin. This helped me out a lot in learning and remembering the chrod combinations.
Also Learn the shortcut Plugin is pretty cool too.

What is the keyboard shortcut to collapse current region in VS2008?

By "current region" I mean a region where the cursor is.
EDIT: I am looking for region toggling, not outlining expansion toggling. By "region" I mean section of code defined by #region and #endregion directives. Ctrl + M, Ctrl + M toggles closest outlining (which for most cases would be current method not region).
CTRL + M, M should do the trick
By the way you can download a "poster" of shortcuts here
It can differ from mapping to mapping but the default is :
Ctrl + M , Ctrl + M
In Visual Studio 2010 use CTRL + M , CTRL + S. I did not check Visual Studio 2008

Visual Studio 2008 - jump to line number shortcut

I can go to a specific line number by double clicking in the status bar in Visual Studio. Is there a keyboard shortcut that does the same thing?
Ctrl + G
Check out all the keyboard shortcuts at:
http://www.microsoft.com/downloads/details.aspx?familyid=e5f902a8-5bb5-4cc6-907e-472809749973&displaylang=en
Ctrl + G works for me.
If it doesn't work for you, you can always map whatever shortcut you want under Tools | Options | Environment | Keyboard.
EDIT: Yes, as #Brian mentions, the command in this case is Edit.GoTo
I just realised that the default in C# settings for this command is Ctrl + G, whereas in VB Settings, there is no default keyboard short - it's mapped to show the immediate window - strange I think. I swapped the mappings so that the two environment behave the same.
Every IDE or even text editor I have ever used either uses Ctrl + L or Ctrl + G for this purpose.
I assume this could stand for Ctrl + Line or Ctrl + Goto
Yep Ctrl + G.
From this answer you can get a nice Shortcut poster.

Resources