Knowledge (XXG)

Syntax highlighting

Source 📝

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

Index

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 decoration

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