Tip: Make parentheses matching more visible in C#

[parentheses]

Recently someone asked me if there was a Visual Studio add-in that highlighted parentheses, brackets, and braces so it would be easier to tell which closing parenthesis matched which opening parenthesis.

It turns out that Visual Studio already has a feature like this. When you place the cursor after a closing parenthesis (for example, the cursor is there right after you type the character), Visual Studio highlights that parenthesis and the matching opening parenthesis. By default the highlighting is light gray so it’s not easy to see, but if you take the following steps you can make it much more obvious.

  • In the Tools menu, select Options
  • In the Options dialog, open the Environment folder and select Fonts and Colors
  • Change “Brace Matching (Rectangle)” to the color you want to use for the highlight. For example, try Yellow or Lime.

The exact appearance of the Options dialog has changed in different versions of Visual Studio, but the general location of this option has remained the same: Tools > Options > Environment > Fonts and Colors, Brace Matching (Rectangle).

Now it will be obvious which parentheses form a pair.


Follow me on Twitter   RSS feed   Donate




This entry was posted in coding, miscellany, tips and tagged , , , , , , , , . Bookmark the permalink.

One Response to Tip: Make parentheses matching more visible in C#

  1. Richard Moss says:

    There’s also a nice extension named Indent Guides (http://visualstudiogallery.msdn.microsoft.com/e792686d-542b-474a-8c55-630980e72c30) that draws dotted lines between them – I find that quite useful too.

Leave a Reply

Your email address will not be published. Required fields are marked *