From Surf Wiki (app.surf) — the open knowledge base
Bracket matching
Bracket matching, also known as brace matching or parentheses matching, is a syntax highlighting feature of certain text editors and integrated development environments that highlights matching sets of brackets (square brackets, curly brackets, or parentheses) in languages such as Java, JavaScript, and C++ that use them. The purpose is to help the programmer navigate through the code and also spot any improper matching, which would cause the program to not compile or malfunction. If a closing bracket is left out, for instance, the compiler will not know that the end of a block of code has been reached. Bracket matching is particularly useful when many nested if statements, program loops, etc. are involved.
Implementations
Vim's % command does bracket matching, and NetBeans has bracket matching built-in. Bracket matching can also be a tool for code navigation. In Visual Studio C++ 6.0, bracket matching behavior was set to ignore brackets found in comments. In VSC 7.0, its behavior was changed to compute commented brackets. IntelliJ IDEA's Ruby on Rails plugin also enables bracket matching. It has been proposed that Perl 5 be modified to facilitate bracket matching. The Microsoft Excel 2003 formula bar has parentheses matching. Its implementation shows all the pairs of parentheses as different colors, so it is possible to easily analyze them all at once.
Example
In this example, the user has just typed the closing curly brace '}' defining a code block, and that brace and its corresponding opening brace are both highlighted.
for (int i = 0; i { System.out.println(i); }│
References
pt:Realce de sintaxe#Parênteses correspondentes
References
- [http://heather.cs.ucdavis.edu/~matloff/ProgEdit/ProgEdit.html#L2314 Norm Matloff's Text-Editor Web Page for Programming Students]
- "Overview (Editor Braces Matching)".
- [http://msdn.microsoft.com/en-us/library/be94e8aw.aspx Automatic Brace Matching in Visual Studio]
- [http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100587 Feedback: braces matching behavior]
- "IntelliJ IDEA supports Ruby and Ruby on Rails {{!}} AjaxLine".
- [http://dev.perl.org/perl6/rfc/145.html Brace-matching for Perl Regular Expressions – perl6]
This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page.
Ask Mako anything about Bracket matching — get instant answers, deeper analysis, and related topics.
Research with MakoFree with your Surf account
Create a free account to save articles, ask Mako questions, and organize your research.
Sign up freeThis content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.
Report