CodeRush Tip – Quickly comment or uncomment code.

Question: “Does CodeRush have any features for helping me to quickly comment or uncomment blocks of code?”

Answer: Yes. CodeRush has function called SelectionComment.

This function comments or uncomments the currently selected block of code using the current language’s single line comment syntax.
The shortcut for this function is the same key as used for the respective language’s single line comment. (ie VB.net uses the ' key and C# or  C++ use the / key)

Simply

  • Select the appropriate code block
  • Press the key suited to that language.* (Either ' or /)

Additionally SelectionComment is actually a toggle command, which means that you can use the same key to uncomment code.

SelectionComment

 

*One small caveat

VB.Net users based in the Uk will need to adjust the SelectionComment shortcut because of the way keyboards of different nationalities and layouts handle scan codes.

The US scan code for ' is the same as the UK scan code for #

To change the key binding

  • Visit the options (Ctrl+Shift+Alt+O)
  • Navigate to IDE\Shortcuts
  • Locate the Selection\Modifying folder in the Shortcuts page.
  • Highlight the # binding
  • Place your caret in the upper right of the dialog where it says Key1: #
  • Specify the key you’d like to bind to (probably ')
  • click Ok

Everything should now be fixed.

You can learn more about binding keys in CodeRush in this blogpost

Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.