This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Visual Studio Go To Brace Command

When working with complex code files, especially those with a large number of conditional statements and loops, it can be difficult to find the end brace that matches a particular starting brace for a block of code. The Go To Brace command makes it easy.

Go To Brace Command

Sometimes you will need to work with large code files containing many conditional statements, loops or other flow-of-control commands. These will usually include code blocks that are surrounded by the brace symbols {}. If the code is very large or overly complex, this is often a sign of poorly written or maintained software that should be refactored. However, it is not always possible to perform such optimisation. In these situations, the complexity and size of the code can make it difficult to identify matching braces, particularly if the code is badly formatted.

Visual Studio provides a useful command called "Go To Brace". This command allows you to select a brace at the start or end of a code block by simply highlighting it or placing the flashing text cursor alongside it. When you execute the Go To Brace command, by pressing Ctrl-], the cursor jumps to the matching brace at the other extreme of the block.

Selecting a Code Block

Sometimes you will want to identify a pair of braces so that you can select them and all of their contained code. This can be achieved with a variation upon the Go To Brace command. Again, place the text cursor alongside either the starting or ending brace for a code block. Pressing Ctrl-Shift-] selects the entire block.

26 December 2008