请输入您要查询的百科知识:

 

词条 Brace matching
释义

  1. Implementations

  2. Example

  3. References

{{primary sources|date=January 2013}}

Brace matching, also known as bracket matching or parentheses matching, is a syntax highlighting feature of certain text editors and integrated development environments that highlights matching sets of braces (square brackets, curly brackets, or parentheses) in languages such as Java 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 brace is left out, for instance, the compiler will not know that the end of a block of code has been reached. Brace matching is particularly useful when many nested if statements, program loops, etc. are involved.

Implementations

Vim's % command does brace matching,[1] and NetBeans has brace matching built-in.[2]

Brace matching can also be a tool for code navigation. In Visual Studio[3] C++ 6.0, brace matching behavior was set to ignore braces found in comments. In VSC 7.0, its behavior was changed to compute commented braces.[4]

IntelliJ IDEA's Ruby on Rails plugin also enables braces matching.[5] It has been proposed that Perl 5 be modified to facilitate braces matching.[6] 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.

{}

References

1. ^Norm Matloff's Text-Editor Web Page for Programming Students
2. ^Overview (Editor Braces Matching)
3. ^Automatic Brace Matching in Visual Studio
4. ^Feedback: braces matching behavior
5. ^IntelliJ IDEA supports Ruby and Ruby on Rails | AjaxLine
6. ^Brace-matching for Perl Regular Expressions - perl6
{{compsci-stub}}Realce de sintaxe#Parênteses correspondentes

2 : User interface techniques|Text editor features

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/14 1:08:13