Brace Matching in C#
Photo by Shotkit from Pexels

Brace Matching in C#

What is Brace Matching?

As C# uses angular braces quite extensively, brace matching helps you identify the corresponding brace pair by highlighting it as shown below.

No alt text provided for this image

By default, the visual studio uses a gray color highlighter to show brace matching, but the user can override the setting.

Tip 1: Changing brace matching default color

Go to Tools > Options > Environment > Fonts and Colors and select the “Brace Matching” item from the Display items list.

No alt text provided for this image

Now choose the foreground & background from the color palette.

Tip 2: Switch between braces with a keyboard shortcut

The above tip is really useful when a file has more lines of code or a larger document, and the user wants to know the starting curly brace of a method, class, or expression.

Shortcut: “Ctrl + ]”

Go to the start or end of any brace and then press the shortcut key. The cursor will move to the start or end of the brace respectively.

No alt text provided for this image

The above live demonstration shows the usage of this tip. To represent the cursor movement, I have written random text to represent where the cursor moved after the shortcut.

Thank you for reading, and I hope you liked the article. Please provide your feedback in the comment section.

Follow me on

C# PublicationLinkedInInstagramTwitterDev.toPinterestSubstackWix.

要查看或添加评论,请登录

Sukhpinder Singh的更多文章

社区洞察

其他会员也浏览了