syntax highlighting
syntax highlighting Syntax highlighting is a feature of text editors that is used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms. This feature facilitates writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct. This feature is also employed in many programming related contexts (such as programming manuals), either in the form of colourful books or online websites to make understanding code snippets easier for readers. Highlighting does not affect the meaning of the text itself; it is intended only for assisting human readers. Syntax highlighting is a form of secondary notation, since the highlights are not part of the text meaning, but serve to reinforce it. Some editors also integrate syntax highlighting with other features, such as spell checking or code folding, as aids to editing which are external to the language.
syntax highlighting Syntax highlighting is a feature of text editors that is used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms. This feature facilitates writing in a structured language such as a programming language or a markup language as both structures and syntax errors are visually distinct. This feature is also employed in many programming related contexts (such as programming manuals), either in the form of colourful books or online websites to make understanding code snippets easier for readers. Highlighting does not affect the meaning of the text itself; it is intended only for assisting human readers. Syntax highlighting is a form of secondary notation, since the highlights are not part of the text meaning, but serve to reinforce it. Some editors also integrate syntax highlighting with other features, such as spell checking or code folding, as aids to editing which are external to the language. ==Practical benefits== Syntax highlighting is one strategy to improve the readability and context of the text, especially for code that spans several pages. The reader can easily ignore large sections of comments or code, depending on what they are looking for. Syntax highlighting also helps programmers find errors in their program. For example, most editors highlight string literals in a different colour. Consequently, spotting a missing delimiter is much easier because of the contrasting colour of the text. Brace matching is another important feature with many popular editors. This makes it simple to see if a brace has been left out or locate the match of the brace the cursor is on by highlighting the pair in a different colour. A study published in the conference PPIG evaluated the effects of syntax highlighting on the comprehension of short programs, finding that the presence of syntax highlighting significantly reduces the time taken for a programmer to internalise the semantics of a program. Additionally, data gathered from an eye-tracker during the study suggested that syntax highlighting enables programmers to pay less attention to standard syntactic components such as keywords. ==Support in text editors== Ruby syntax highlighting Some text editors can also export the coloured markup in a format that is suitable for printing or for importing into word-processing and other kinds of text-formatting software; for instance as a HTML, colourized LaTeX, PostScript or RTF version of its syntax highlighting. There are several syntax highlighting libraries or "engines" that can be used in other applications, but are not complete programs in themselves, for example the Generic Syntax Highlighter (GeSHi) extension for PHP. For editors that support more than one language, the user can usually specify the language of the text, such as C, LaTeX, HTML, or the text editor can automatically recognize it based on the file extension or by scanning contents of the file. This automatic language detection presents potential problems. For example, a user may want to edit a document containing: more than one language (for example when editing an HTML file that contains embedded JavaScript code), a language that is not recognized (for example when editing source code for an obscure or relatively new programming language), a language that differs from the file type (for example when editing source code in an extension-less file in an editor that uses file extensions to detect the language). In these cases, it is not clear what language to use, and a document may not be highlighted or be highlighted incorrectly. Some tools, like Guesslang and PLangRec, are designed to detect the programming language from the source code. ==Syntax elements== Most editors with syntax highlighting allow different colours and text styles to be given to dozens of different lexical sub-elements of syntax. These include keywords, comments, control-flow statements, variables, and other elements. Programmers often heavily customize their settings in an attempt to show as much useful information as possible without making the code difficult to read. Called syntax decoration, some editors also display certain syntactical elements in more visually pleasing ways, for example by replacing a pointer operator like -> in source code by an actual arrow symbol (→), or changing text decoration clues like /italics/, *boldface*, or _underline_ in source code comments by an actual italics, boldface, or underlined presentation. ===Examples=== Below is a comparison of a snippet of C code: Below is another snippet of syntax highlighted C++ code: import std; using std::array; using std::shared_ptr; constexpr size_t MAX_WINDOW_COUNT = 100; // Create Window objects and store them in windows: const int windowCount = 10; array , MAX_WINDOW_COUNT> windows = {}; for (size_t i = 0; i (); } In the C++ example, the editor recognizes and highlights several C++ keywords. The comment at the beginning is also highlighted in a specific manner to distinguish it from working code. ==History and limitations== The ideas of syntax highlighting overlap significantly with those of syntax-directed editors. One of the first such editors for code was Wilfred Hansen's 1969 code editor, Emily. It provided advanced language-independent code completion facilities, and unlike modern editors with syntax highlighting, actually made it impossible to create syntactically incorrect programs. In 1982, Anita H. Klock and Jan B. Chodak filed a patent for the first known syntax highlighting system, which was used in the Intellivision's Entertainment Computer System (ECS) peripheral, released in 1983. It would highlight different elements of BASIC programs and was implemented in an attempt to make it easier for beginners, especially children, to start writing code. Later, the Live Parsing Editor (LEXX) written for the VM operating system for the computerization of the Oxford English Dictionary in 1985 was one of the first to use colour syntax highlighting. Its live parsing capability allowed user-supplied parsers to be added to the editor, for text, programs, data file, etc. On microcomputers, MacPascal 1.0 (October 10, 1985) recognized Pascal syntax as it was typed and used font changes (e.g., bold for keywords) to highlight syntax on the monochrome compact Macintosh and automatically indented code to match its structure. Some text editors and code formatting tools perform syntax highlighting using pattern matching heuristics (e.g. regular expressions) rather than implementing a parser for each possible language. This can result in a text rendering system displaying somewhat inaccurate syntax highlighting and in some cases performing slowly. A solution used by text editors to overcome this problem is not always parsing the whole file but rather just the visible area, sometimes scanning backwards in the text up to a limited number of lines for "syncing". On the other hand, the editor often displays code during its creation, while it is incomplete or incorrect, and the strict parsers (like ones used in compilers) would fail to parse the code most of the time. Some modern, language-specific IDEs (in contrast to text editors) perform full language parsing which can help make the code easier to understand. An extension of syntax highlighting was called "semantic highlighting" in 2009 by David Nolden for the open-source C++ IDE KDevelop. For example, semantic highlighting may give local variables unique distinct colours to improve the comprehensibility of code. In 2014, the idea of coloured local variables was further popularized due to a blog post by Evan Brooks, and after that, the idea was transferred to other popular IDEs like Visual Studio, Xcode, and others. Colour in a user interface is less useful if the user has some degree of colour blindness. ==See also== Programming features in a Comparison of text editors Indentation style Secondary notation Structure editor Parsing Solarized ==References==
References
- Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). The Java developer's guide to Eclipse (2nd ed.). Boston: Addison-Wesley. ISBN 978-0-321-30502-2 . Wikipedia revision 1377048330, retrieved 2026-11-19 · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). The Java developer's guide to Eclipse (2nd ed.). Boston: Addison-Wesley. ISBN 978-0-321-30502-2 . Wikipedia revision 1377048330, retrieved 2026-11-19." Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). 2026-11-18. https://en.wikipedia.org/wiki/ISBN_(identifier). Accessed 24 November 2026.
Chicago "Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). The Java developer's guide to Eclipse (2nd ed.). Boston: Addison-Wesley. ISBN 978-0-321-30502-2 . Wikipedia revision 1377048330, retrieved 2026-11-19." Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). 2026-11-18. https://en.wikipedia.org/wiki/ISBN_(identifier).
APA Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). (2026). Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005). The Java developer's guide to Eclipse (2nd ed.). Boston: Addison-Wesley. ISBN 978-0-321-30502-2 . Wikipedia revision 1377048330, retrieved 2026-11-19. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/ISBN_(identifier)
- KEDIT Language Definition Files · retrieved 2016-04-06 · rev 1377048330
Cite this reference
MLA "KEDIT Language Definition Files." 2016-04-06. http://www.kedit.com/wwkld.html. Accessed 24 November 2026.
Chicago "KEDIT Language Definition Files." 2016-04-06. http://www.kedit.com/wwkld.html.
APA encyclopegia.org. (2016). KEDIT Language Definition Files. Retrieved November 24, 2026, from http://www.kedit.com/wwkld.html
- 2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden." 2026-11-18. http://zwabel.wordpress.com/2009/01/08/c-ide-evolution-from-syntax-highlighting-to-semantic-highlighting/. Accessed 24 November 2026.
Chicago "2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden." 2026-11-18. http://zwabel.wordpress.com/2009/01/08/c-ide-evolution-from-syntax-highlighting-to-semantic-highlighting/.
APA encyclopegia.org. (2026). 2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden. Retrieved November 24, 2026, from http://zwabel.wordpress.com/2009/01/08/c-ide-evolution-from-syntax-highlighting-to-semantic-highlighting/
- 2014 blog post on Semantic Highlighting by Evan Brooks · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "2014 blog post on Semantic Highlighting by Evan Brooks." Brooks, Evan (17 April 2017). 2026-11-18. https://medium.com/@evnbr/coding-in-color-3a6db2743a1e. Accessed 24 November 2026.
Chicago "2014 blog post on Semantic Highlighting by Evan Brooks." Brooks, Evan (17 April 2017). 2026-11-18. https://medium.com/@evnbr/coding-in-color-3a6db2743a1e.
APA Brooks, Evan (17 April 2017). (2026). 2014 blog post on Semantic Highlighting by Evan Brooks. Retrieved November 24, 2026, from https://medium.com/@evnbr/coding-in-color-3a6db2743a1e
- Visual Studio Magazine article on semantic highlighting · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "Visual Studio Magazine article on semantic highlighting." 2026-11-18. http://visualstudiomagazine.com/articles/2014/08/01/semantic-code-highlighting.aspx. Accessed 24 November 2026.
Chicago "Visual Studio Magazine article on semantic highlighting." 2026-11-18. http://visualstudiomagazine.com/articles/2014/08/01/semantic-code-highlighting.aspx.
APA encyclopegia.org. (2026). Visual Studio Magazine article on semantic highlighting. Retrieved November 24, 2026, from http://visualstudiomagazine.com/articles/2014/08/01/semantic-code-highlighting.aspx
- Github page of a plugin which implements semantic highlighting for Xcode · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "Github page of a plugin which implements semantic highlighting for Xcode." 2026-11-18. https://github.com/kolinkrewinkel/Polychromatic. Accessed 24 November 2026.
Chicago "Github page of a plugin which implements semantic highlighting for Xcode." 2026-11-18. https://github.com/kolinkrewinkel/Polychromatic.
APA encyclopegia.org. (2026). Github page of a plugin which implements semantic highlighting for Xcode. Retrieved November 24, 2026, from https://github.com/kolinkrewinkel/Polychromatic
- Emily - An Editor for Structured Text · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "Emily - An Editor for Structured Text." Hansen, Wilfred. 2026-11-18. https://www.cs.cmu.edu/~wjh/Emily.html. Accessed 24 November 2026.
Chicago "Emily - An Editor for Structured Text." Hansen, Wilfred. 2026-11-18. https://www.cs.cmu.edu/~wjh/Emily.html.
APA Hansen, Wilfred. (2026). Emily - An Editor for Structured Text. Retrieved November 24, 2026, from https://www.cs.cmu.edu/~wjh/Emily.html
- Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieved 2026-11-19 · retrieved 2018-04-11 · rev 1377048330
Cite this reference
MLA "Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieved 2026-11-19." Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieve. 2018-04-11. https://patents.google.com/patent/US4617643A/en. Accessed 24 November 2026.
Chicago "Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieved 2026-11-19." Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieve. 2018-04-11. https://patents.google.com/patent/US4617643A/en.
APA Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieve. (2018). Syntax error correction method and apparatus , 1982-10-29 , retrieved 2018-04-12 Wikipedia revision 1377048330, retrieved 2026-11-19. Retrieved November 24, 2026, from https://patents.google.com/patent/US4617643A/en
- Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US) . 1983. Wikipedia revision 1377048330, retrieved 2026-11-19 · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US) . 1983. Wikipedia revision 1377048330, retrieved 2026-11-19." Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US). 2026-11-18. https://archive.org/details/Intellivision_Computer_Module_Owners_Guide_1983_Mattel_US. Accessed 24 November 2026.
Chicago "Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US) . 1983. Wikipedia revision 1377048330, retrieved 2026-11-19." Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US). 2026-11-18. https://archive.org/details/Intellivision_Computer_Module_Owners_Guide_1983_Mattel_US.
APA Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US). (2026). Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US) . 1983. Wikipedia revision 1377048330, retrieved 2026-11-19. Retrieved November 24, 2026, from https://archive.org/details/Intellivision_Computer_Module_Owners_Guide_1983_Mattel_US
- Intellivision Classic Video Game System / Entertainment Computer System · retrieved 2018-04-11 · rev 1377048330
Cite this reference
MLA "Intellivision Classic Video Game System / Entertainment Computer System." 2018-04-11. https://web.archive.org/web/20180717123313/http://www.intellivisionlives.com/bluesky/hardware/ecs_tech.html. Accessed 24 November 2026.
Chicago "Intellivision Classic Video Game System / Entertainment Computer System." 2018-04-11. https://web.archive.org/web/20180717123313/http://www.intellivisionlives.com/bluesky/hardware/ecs_tech.html.
APA encyclopegia.org. (2018). Intellivision Classic Video Game System / Entertainment Computer System. Retrieved November 24, 2026, from https://web.archive.org/web/20180717123313/http://www.intellivisionlives.com/bluesky/hardware/ecs_tech.html
- LEXX – A programmable structured editor · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "LEXX – A programmable structured editor." Cowlishaw, M. 2026-11-18. https://en.wikipedia.org/wiki/Mike_Cowlishaw. Accessed 24 November 2026.
Chicago "LEXX – A programmable structured editor." Cowlishaw, M. 2026-11-18. https://en.wikipedia.org/wiki/Mike_Cowlishaw.
APA Cowlishaw, M. (2026). LEXX – A programmable structured editor. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Mike_Cowlishaw
- The impact of syntax colouring on program comprehension · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "The impact of syntax colouring on program comprehension." Sarkar, Advait (2015). 2026-11-18. https://ppig.org/papers/2015-ppig-26th-sarkar1/. Accessed 24 November 2026.
Chicago "The impact of syntax colouring on program comprehension." Sarkar, Advait (2015). 2026-11-18. https://ppig.org/papers/2015-ppig-26th-sarkar1/.
APA Sarkar, Advait (2015). (2026). The impact of syntax colouring on program comprehension. Retrieved November 24, 2026, from https://ppig.org/papers/2015-ppig-26th-sarkar1/
- PLangRec: Deep-learning model to predict the programming language from a single line of code · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "PLangRec: Deep-learning model to predict the programming language from a single line of code." a b Oscar Rodriguez-Prieto; Alejandro Pato; Francisco Ortin (2025). 2026-11-18. https://doi.org/10.1016%2Fj.future.2024.107640. Accessed 24 November 2026.
Chicago "PLangRec: Deep-learning model to predict the programming language from a single line of code." a b Oscar Rodriguez-Prieto; Alejandro Pato; Francisco Ortin (2025). 2026-11-18. https://doi.org/10.1016%2Fj.future.2024.107640.
APA a b Oscar Rodriguez-Prieto; Alejandro Pato; Francisco Ortin (2025). (2026). PLangRec: Deep-learning model to predict the programming language from a single line of code. Retrieved November 24, 2026, from https://doi.org/10.1016%2Fj.future.2024.107640
- User engineering principles for interactive systems · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "User engineering principles for interactive systems." Hansen, Wilfred J. 2026-11-18. https://en.wikipedia.org/w/index.php?oldid=1377048330. Accessed 24 November 2026.
Chicago "User engineering principles for interactive systems." Hansen, Wilfred J. 2026-11-18. https://en.wikipedia.org/w/index.php?oldid=1377048330.
APA Hansen, Wilfred J. (2026). User engineering principles for interactive systems. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1377048330
- A Trio of Historical Recollections · retrieved 2026-11-18 · rev 1377048330
Cite this reference
MLA "A Trio of Historical Recollections." Allen, Dan (2011-10-10). 2026-11-18. https://en.wikipedia.org/wiki/Bruce_Perens. Accessed 24 November 2026.
Chicago "A Trio of Historical Recollections." Allen, Dan (2011-10-10). 2026-11-18. https://en.wikipedia.org/wiki/Bruce_Perens.
APA Allen, Dan (2011-10-10). (2026). A Trio of Historical Recollections. Retrieved November 24, 2026, from https://en.wikipedia.org/wiki/Bruce_Perens
- syntax highlighting · retrieved 2026-10-19 · rev 1377048330
Cite this reference
MLA "syntax highlighting." Wikipedia. 2026-10-19. https://en.wikipedia.org/w/index.php?oldid=1377048330. Accessed 24 November 2026.
Chicago "syntax highlighting." Wikipedia. 2026-10-19. https://en.wikipedia.org/w/index.php?oldid=1377048330.
APA Wikipedia. (2026). syntax highlighting. Retrieved November 24, 2026, from https://en.wikipedia.org/w/index.php?oldid=1377048330
Cite this article
MLA
"syntax highlighting." encyclopegia.org, 2026, https://encyclopegia.org/wiki/syntax-highlighting. Accessed 24 November 2026.
Chicago
"syntax highlighting." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/syntax-highlighting.
APA
encyclopegia.org. (2026). syntax highlighting. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/syntax-highlighting
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON
Claims
| Predicate | Value | Source |
|---|---|---|
| release date | 1983 | Wikipedia |