Brace Matching

Programming languages make use of parentheses, braces, brackets, and other delimiters to delimit function arguments, mathematical functions/order of operation, and bodies of code. It can be difficult to visually determine whether you have missed a matching delimiter—that is, if you have more opening delimiters than you have closing delimiters—especially with highly nested lines of code.

Brace matching refers to visual cues that the code editor uses to make you aware of your matching delimiters. As you type code into the editor, any time you enter a closing delimiter, the matching opening delimiter and the closing delimiter are briefly highlighted. In Figure 7.25, brace matching helps to indicate the matching delimiters for the interior for loop.

Image

FIGURE 7.25 Brace matching.


Tip

You also can trigger brace matching simply by placing the cursor directly to the left of an opening delimiter or the right of a closing delimiter. If you are browsing through a routine congested with parentheses and braces, you can quickly sort out the matching pairs by moving your cursor around to the various delimiters. If you want to move to the second member of a pair, you can press Ctrl+^.


Although this feature is referred to as brace matching, it actually functions with the following delimiters:

Image Parentheses: ()

Image Brackets: [], <>

Image Quotation marks: ""

Image Braces: {}

In the case of C#, brace matching also works with the following keyword pairs (which essentially function as delimiters using keywords):

Image #region, #endregion

Image #if, #else, #endif

Image case, break

Image default, break

Image for, break, continue

Image if, else

Image while, break, continue

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset