How to quickly comment or uncomment lines of code in Visual Studio
When I am developing I am always trying to reduce the amount of time that my hands come off of the keyboard and have to move to the mouse. One of the frequent functions that I noticed required me to move my hand off of the keyboard to the mouse is commenting or uncommenting lines of code.
Visual Studio has two buttons in the toolbar to comment or uncomment a line of code (they are part of the Text Editor or HTML Source Editing Toolbars):
You can also achieve the same result by using the key combination Ctrl-K, Ctrl-C to comment out the currently selected lines or Ctrl-K, Ctrl-U to uncomment the currently selected lines.
Ctrl-K, Ctrl-C means to hold down the Control key and then press K and then while still holding down the Control key press C. Ctrl-K, Ctrl-U means to hold down the Control key and then press K and then while still holding down the Control key press U.
I have found this key combination to be difficult at first to remember (in the past I tended to always just instinctively go for my mouse) but now I have remembered to use that key combination regularly and have found it very helpful.