Knowledge (XXG)

Syntax highlighting

Source 📝

38: 146: 218:
Most editors with syntax highlighting allow different colors 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
79:
are visually distinct. This feature is also employed in many programming related contexts (such as programming manuals), either in the form of colorful books or online websites to make understanding code snippets easier for readers. Highlighting does not affect the meaning of the text itself; it is
633:. For example, semantic highlighting may give local variables unique distinct colors to improve the comprehensibility of code. In 2014 the idea of colored 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 613:
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
115:
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
136:
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
104: 188:, 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: 565:(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 ( 156:
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, colorized LaTeX,
128:
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 color.
617:
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.
75:, 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 206:
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).
169:
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
625:(in contrast to text editors) perform full language parsing which results in very accurate understanding of code. An extension of syntax highlighting was called 87:, 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 740: 591:(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 561:
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
837: 895: 715: 952: 1020: 226:, some editors also display certain syntactical elements in more visually pleasing ways, for example by replacing a pointer operator like 278:/* Hello World */ #include <stdlib.h> #include <stdio.h> int main() { printf("Hello World\n"); return 0; } 558:
facilities, and unlike modern editors with syntax highlighting, actually made it impossible to create syntactically incorrect programs.
1025: 622: 554:. One of the first such editors for code was Wilfred Hansen's 1969 code editor, Emily. It provided advanced language-independent 137:
suggested that syntax highlighting enables programmers to pay less attention to standard syntactic components such as keywords.
31: 203:
a language that is not recognized (for example when editing source code for an obscure or relatively new programming language),
539: 520: 210:
In these cases, it is not clear what language to use, and a document may not be highlighted or be highlighted incorrectly.
1030: 562: 821: 980: 661: 657: 575: 133: 176:
For editors that support more than one language, the user can usually specify the language of the text, such as
686: 259: 177: 583:
capability allowed user-supplied parsers to be added to the editor, for text, programs, data file, etc. On
570: 255: 56: 845: 606: 166: 903: 103: 671: 566: 84: 60: 542:
at the beginning is also highlighted in a specific manner to distinguish it from working code.
711: 706:
Jim D'Anjou; Sherry Shavor; Scott Fairbrother; Dan Kehn; John Kellerman; Pat McCarthy (2005).
592: 870: 676: 599: 551: 162: 878:
IBM Journal of Research and Development, Vol 31, No. 1, IBM Reprint order number G322-0151
645: 231: 64: 37: 966: 737:
Proceedings of the 26th Annual Conference of the Psychology of Programming Interest Group
866: 584: 219:
show as much useful information as possible without making the code difficult to read.
125: 121: 117: 88: 234:
clues like /italics/, *boldface*, or _underline_ in source code comments by an actual
145: 1014: 634: 823:
Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US)
891: 666: 555: 92: 76: 994: 799: 762:
Hansen, Wilfred J. (1971). "User engineering principles for interactive systems".
732: 17: 953:"2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden" 72: 52: 614:
scanning backwards in the text up to a limited number of lines for "syncing".
602: 598:
Some text editors and code formatting tools perform syntax highlighting using
197: 158: 995:"Github page of a plugin which implements semantic highlighting for Xcode" 165:
version of its syntax highlighting. There are several syntax highlighting
30:
For syntax highlighting on Knowledge (XXG) and other MediaWiki wikis, see
838:"Intellivision Classic Video Game System / Entertainment Computer System" 778: 630: 644:
Color in a user interface is less useful if the user has some degree of
681: 999: 610: 550:
The ideas of syntax highlighting overlap significantly with those of
579:
in 1985 was one of the first to use color syntax highlighting. Its
350: 930: 925: 638: 181: 149: 102: 36: 193: 185: 68: 41: 170: 124:
is much easier because of the contrasting color of the text.
230:
in source code by an actual arrow symbol (→), or changing
981:"Visual Studio Magazine article on semantic highlighting" 764:
Proceedings of the Fall Joint Computer Conference FJCC 39
733:"The impact of syntax colouring on program comprehension" 95:, as aids to editing which are external to the language. 967:"2014 blog post on Semantic Highlighting by Evan Brooks" 595:
and automatically indented code to match its structure.
120:
in a different color. Consequently, spotting a missing
27:
Tool of editors for programming, scripting, and markup
264: 629:
in 2009 by David Nolden for the open-source C++ IDE
192:
more than one language (for example when editing an
107:
Highlighting the effect of missing delimiter (after
116:their program. For example, most editors highlight 519:In the C++ example, the editor has recognized the 358:// Create "window_count" Window objects: 573:operating system for the computerization of the 349:Below is another snippet of syntax highlighted 871:"LEXX – A programmable structured editor" 8: 801:Syntax error correction method and apparatus 710:(2nd ed.). Boston: Addison-Wesley. 144: 71:. The feature displays text, especially 779:"Emily - An Editor for Structured Text" 698: 743:from the original on 24 September 2015 934:. Mansfield Software Group, Inc. 2012 708:The Java developer's guide to Eclipse 7: 896:"A Trio of Historical Recollections" 132:A study published in the conference 32:Knowledge (XXG):Syntax highlighting 25: 926:"KEDIT Language Definition Files" 83:Syntax highlighting is a form of 80:intended only for human readers. 621:Some modern, language-specific 902:(Mailing list). Archived from 1: 609:) rather than implementing a 563:Entertainment Computer System 196:file that contains embedded 152:supports syntax highlighting 1021:Programming language syntax 766:. AFIPS. pp. 5623–532. 254:Below is a comparison of a 1047: 842:www.intellivisionlives.com 662:Comparison of text editors 29: 1026:User interface techniques 576:Oxford English Dictionary 687:Solarized (color scheme) 355: 283: 276: 731:Sarkar, Advait (2015). 627:"semantic highlighting" 552:syntax-directed editors 546:History and limitations 141:Support in text editors 153: 112: 45: 148: 106: 40: 1031:Text editor features 1003:. 14 September 2022. 658:Programming features 271:Syntax highlighting 607:Regular expressions 268:Standard rendering 67:languages, such as 49:Syntax highlighting 44:syntax highlighting 672:Secondary notation 569:) written for the 154: 113: 99:Practical benefits 85:secondary notation 46: 955:. 8 January 2009. 777:Hansen, Wilfred. 717:978-0-321-30502-2 593:compact Macintosh 347: 346: 319:"Hello World 286:/* Hello World */ 224:syntax decoration 55:that is used for 18:Syntax decoration 16:(Redirected from 1038: 1005: 1004: 991: 985: 984: 977: 971: 970: 969:. 17 April 2017. 963: 957: 956: 949: 943: 942: 940: 939: 922: 916: 915: 913: 911: 888: 882: 881: 875: 867:Cowlishaw, M. F. 863: 857: 856: 854: 853: 844:. Archived from 834: 828: 827: 818: 812: 811: 810: 809: 796: 790: 789: 787: 785: 774: 768: 767: 759: 753: 752: 750: 748: 728: 722: 721: 703: 677:Structure editor 600:pattern matching 537: 533: 529: 525: 515: 512: 509: 506: 503: 500: 497: 494: 491: 488: 485: 482: 479: 476: 473: 470: 467: 464: 461: 458: 455: 452: 449: 446: 443: 440: 437: 434: 431: 428: 427:max_window_count 425: 422: 419: 416: 413: 410: 407: 404: 401: 398: 395: 392: 389: 386: 383: 380: 377: 374: 371: 368: 365: 362: 359: 341: 338: 335: 332: 329: 326: 323: 320: 317: 314: 311: 308: 305: 302: 299: 296: 293: 292:<stdlib.h> 290: 287: 265: 229: 51:is a feature of 21: 1046: 1045: 1041: 1040: 1039: 1037: 1036: 1035: 1011: 1010: 1009: 1008: 993: 992: 988: 979: 978: 974: 965: 964: 960: 951: 950: 946: 937: 935: 924: 923: 919: 909: 907: 890: 889: 885: 873: 865: 864: 860: 851: 849: 836: 835: 831: 820: 819: 815: 807: 805: 798: 797: 793: 783: 781: 776: 775: 771: 761: 760: 756: 746: 744: 730: 729: 725: 718: 705: 704: 700: 695: 654: 646:color blindness 556:code completion 548: 535: 531: 527: 523: 517: 516: 513: 510: 507: 504: 501: 498: 495: 492: 489: 486: 483: 480: 477: 474: 471: 468: 465: 462: 459: 456: 453: 450: 447: 444: 441: 438: 435: 432: 429: 426: 423: 420: 417: 414: 411: 408: 405: 402: 399: 396: 393: 390: 387: 384: 381: 378: 375: 372: 369: 366: 363: 360: 357: 343: 342: 339: 336: 333: 330: 327: 324: 321: 318: 315: 312: 309: 306: 303: 300: 298:<stdio.h> 297: 294: 291: 288: 285: 280: 279: 252: 232:text decoration 227: 216: 214:Syntax elements 143: 118:string literals 111:) in JavaScript 101: 35: 28: 23: 22: 15: 12: 11: 5: 1044: 1042: 1034: 1033: 1028: 1023: 1013: 1012: 1007: 1006: 986: 972: 958: 944: 917: 894:(2011-10-10). 883: 858: 829: 813: 791: 769: 754: 723: 716: 697: 696: 694: 691: 690: 689: 684: 679: 674: 669: 664: 653: 650: 641:, and others. 585:microcomputers 547: 544: 356: 345: 344: 284: 281: 277: 273: 272: 269: 251: 248: 246:presentation. 215: 212: 208: 207: 204: 201: 142: 139: 126:Brace matching 100: 97: 89:spell checking 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1043: 1032: 1029: 1027: 1024: 1022: 1019: 1018: 1016: 1002: 1001: 996: 990: 987: 982: 976: 973: 968: 962: 959: 954: 948: 945: 933: 932: 927: 921: 918: 906:on 2017-08-21 905: 901: 897: 893: 887: 884: 879: 872: 868: 862: 859: 848:on 2018-07-17 847: 843: 839: 833: 830: 825: 824: 817: 814: 803: 802: 795: 792: 780: 773: 770: 765: 758: 755: 742: 738: 734: 727: 724: 719: 713: 709: 702: 699: 692: 688: 685: 683: 680: 678: 675: 673: 670: 668: 665: 663: 659: 656: 655: 651: 649: 647: 642: 640: 636: 635:Visual Studio 632: 628: 624: 619: 615: 612: 608: 604: 601: 596: 594: 590: 589:MacPascal 1.0 586: 582: 578: 577: 572: 568: 564: 559: 557: 553: 545: 543: 541: 522: 354: 352: 282: 275: 274: 270: 267: 266: 263: 261: 257: 249: 247: 245: 241: 237: 233: 225: 220: 213: 211: 205: 202: 199: 195: 191: 190: 189: 187: 183: 179: 174: 172: 168: 164: 160: 151: 147: 140: 138: 135: 130: 127: 123: 119: 110: 105: 98: 96: 94: 90: 86: 81: 78: 77:syntax errors 74: 70: 66: 62: 58: 54: 50: 43: 39: 33: 19: 998: 989: 975: 961: 947: 936:. Retrieved 929: 920: 910:12 September 908:. Retrieved 904:the original 899: 886: 877: 861: 850:. Retrieved 846:the original 841: 832: 822: 816: 806:, retrieved 804:, 1982-10-29 800: 794: 782:. Retrieved 772: 763: 757: 747:27 September 745:. Retrieved 736: 726: 707: 701: 667:Indent style 643: 626: 620: 616: 597: 588: 581:live parsing 580: 574: 560: 549: 518: 469:window_count 367:window_count 348: 253: 243: 239: 235: 223: 221: 217: 209: 175: 155: 131: 114: 109:watch='false 108: 93:code folding 82: 53:text editors 48: 47: 499:make_shared 73:source code 57:programming 1015:Categories 938:2016-04-07 892:Allen, Dan 852:2018-04-12 808:2018-04-12 693:References 603:heuristics 412:shared_ptr 244:underlined 198:JavaScript 159:PostScript 739:: 49–58. 167:libraries 122:delimiter 61:scripting 869:(1987). 741:Archived 652:See also 631:KDevelop 538:. The 521:keywords 295:#include 289:#include 250:Examples 240:boldface 900:mpw-dev 826:. 1983. 784:17 June 682:Parsing 540:comment 487:windows 388:windows 256:snippet 236:italics 222:Called 1000:GitHub 880:. IBM. 714:  611:parser 605:(e.g. 534:, and 505:Window 418:Window 353:code: 331:return 325:" 313:printf 262:code: 200:code), 65:markup 931:Kedit 874:(PDF) 660:in a 639:Xcode 524:const 400:array 361:const 242:, or 228:-> 182:LaTeX 150:gedit 63:, or 912:2019 786:2013 749:2023 712:ISBN 623:IDEs 567:LEXX 528:auto 508:> 502:< 466:< 442:auto 430:> 421:> 415:< 403:< 385:auto 364:auto 304:main 194:HTML 186:HTML 134:PPIG 69:HTML 42:HTML 536:for 532:int 511:(); 493:std 451:int 436:for 433:{}; 406:std 394:std 373:int 351:C++ 301:int 258:of 171:PHP 163:RTF 161:or 91:or 1017:: 997:. 928:. 898:. 876:. 840:. 735:. 648:. 637:, 587:, 571:VM 530:, 526:, 496::: 475:++ 460:}; 409::: 397::: 382:}; 379:10 328:); 322:\n 307:() 238:, 184:, 180:, 173:. 59:, 983:. 941:. 914:. 855:. 788:. 751:. 720:. 514:} 490:= 484:{ 481:) 478:i 472:; 463:i 457:0 454:{ 448:= 445:i 439:( 424:, 391:= 376:{ 370:= 340:} 337:; 334:0 316:( 310:{ 260:C 178:C 34:. 20:)

Index

Syntax decoration
Knowledge (XXG):Syntax highlighting

HTML
text editors
programming
scripting
markup
HTML
source code
syntax errors
secondary notation
spell checking
code folding

string literals
delimiter
Brace matching
PPIG

gedit
PostScript
RTF
libraries
PHP
C
LaTeX
HTML
HTML
JavaScript

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.