按摩手推是什么意思| 剪切是什么意思| wbc是什么意思医学| 烟酒不沾的人什么性格| 卡路里什么意思| 眼袋是什么原因引起的| 性格缺陷是什么意思| 止汗药什么最好| 女无是什么字| 两个b型血能生出什么血型的孩子| 什么能解酒| 压床娃娃有什么讲究吗| 阴虚什么意思| 孩子手抖是什么原因| 睡不着觉去医院挂什么科| 口腔扁平苔藓吃什么药好得快| 备孕喝豆浆有什么好处| 夏天适合吃什么菜| 紫色加绿色是什么颜色| 颈椎病用什么药| 骑驴找马什么意思| 张伦硕为什么娶钟丽缇| 草缸适合养什么鱼| 头皮上长疣是什么原因造成的| 补钙什么时间段最好| 微信附近的人都是些什么人| 牙龈肿痛吃什么中成药| 不割包皮有什么影响吗| 气血不足吃什么比较好| 梦见做手术是什么意思| 深喉是什么意思| 框镜鱼是什么鱼| 有鸟飞进屋是什么预兆| 为什么拔牙后不能吐口水| 唇炎涂什么药膏| 特效药是什么意思| 经期适合什么运动| 秋葵不适宜什么人吃| crispi是什么牌子| 例假提前是什么原因| 泥灸是什么| 痛风该吃什么药好得快| 苦瓜泡酒有什么功效和作用| 恨不相逢未嫁时什么意思| 餐补是什么意思| 十万为什么| 江苏有什么烟| 女人没经验开什么店好| 抉择是什么意思| 脂肪是什么意思| 看正月初一是什么生肖| 铁是什么颜色| 女人平胸是什么原因| 客单价什么意思| 阳痿什么意思| 舒肝解郁胶囊治什么病| 前胸后背出汗多是什么原因| 胆管炎是什么原因引起的| 丧偶是什么意思| 车震是什么意思啊| 复方什么意思| 煤气罐在什么情况下会爆炸| 秦始皇的母亲叫什么名字| 九月23日是什么星座| 耳仓为什么是臭的| 马甲是什么意思?| 什么水果热量低| 酸奶对人体有什么好处| 铁观音是什么茶| 棉花什么时候传入中国| 黄精是什么东西| 宫内膜回声不均匀是什么意思| 出水痘不能吃什么食物| 珍珠是用什么做的| 什么是sop流程| 羊驼吃什么| dic是什么病| 盐酸盐是什么| 护理主要学什么| 树懒是什么动物| 善茬是什么意思| 西安有什么区| 1月23号什么星座| 猫的眼睛为什么会发光| 打摆子是什么病| 还人是什么意思| 惊恐发作是什么病| 轴向是什么意思| eoa是什么意思| 小孩记忆力差需要补充什么营养| 扶她是什么意思| 什么是正缘| 市委副秘书长什么级别| 肝火旺盛吃什么食物| ft什么意思| 为什么家里会有隐翅虫| 白衬衫太透里面穿什么| 朋友越来越少暗示什么| 泪目是什么意思| 椰子什么时候成熟| 德国是什么民族| 十九朵玫瑰花代表什么意思| 编者按是什么| 怀孕一个星期有什么症状| 苦菜是什么菜| 88年属什么| 后背发麻是什么原因| 宝宝睡觉流口水是什么原因| 耳蜗是什么东西| 悬壶济世是什么意思| 0n是什么意思| 五花肉和什么菜炒好吃| 隔空打牛是什么意思| 长公主是什么意思| 画眉是什么| 小熊猫长什么样| 狗狗打疫苗前后要注意什么| 113是什么意思| 胎盘附着于子宫前壁是什么意思| a21和以纯什么关系| 脑白质是什么| 孩子咳嗽有痰吃什么药| 嘴里苦是什么原因| 二氧化碳是什么东西| 2025是什么年| 甲亢查什么项目| 什么是命中注定| 综艺是什么意思| 吃什么补钾最快| 奶黄包的馅是什么做的| 2100年是什么年| 高五行属什么| 向日葵的花语是什么| 真实的印度是什么样的| 长方脸适合什么样的发型| 尿毒症挂什么科| 书香门第的书香指什么| 晴纶是什么材质| 更年期燥热吃什么食物| 维生素b不能和什么一起吃| 硬膜囊受压是什么意思| 肾内科是看什么病的| 喝白酒有什么好处| 风疟病是什么意思| 心机血缺血是什么症状| 房性心动过速是什么意思| 保胎针是什么药| 女性气血不足吃什么调理| 血铅是什么| 疱疹挂号挂什么科室| 猫怕什么气味| 大张伟的真名叫什么| 护理和护士有什么区别| sama是什么药| 什么纸贵| 女人小便疼是什么原因| 正月十九是什么日子| 早泄用什么药| 怀孕10多天有什么症状| 女人小便疼是什么原因| 秋葵不能和什么一起吃| 经产妇是什么意思| 桑葚搭配什么泡水喝最好| 舌头两侧溃疡吃什么药| 端粒是什么| 下肢静脉曲张是什么原因引起的| 肥什么拱门成语| 丹毒用什么抗生素| 面色发黄是什么原因| 体格检查是什么意思| 正月是什么意思| 你喜欢我什么| 误会是什么意思| 心脏做什么检查最准确| 吃什么都是苦的是怎么回事| 正缘是什么| cs是什么元素| 蜈蚣代表什么生肖| 女孩名字带什么字好听| 怀孕吸烟对胎儿有什么影响| lemon是什么意思| 搪塞什么意思| 乳腺囊性增生是什么意思| 参苓白术散治什么病| 我一言难尽忍不住伤心是什么歌| 虫至念什么| 宗师是什么意思| 青梅是什么水果| 穆斯林为什么不吃猪肉| 悔教夫婿觅封侯是什么意思| 乘务员是干什么的| 亚是什么意思| 黄仙是什么仙| 睡不着觉吃什么药效果好| 霸王别姬讲的是什么故事| mrr是什么意思| 喝什么牌子的水最健康| ir是什么意思| 脸部肿胀是什么原因| 5.7是什么星座| 5月15日什么星座| 穿山甲到底说了什么| alk是什么意思| 睡觉口苦是什么原因| 什么男什么女| 为什么老是抽筋| 心痛定又叫什么| 耳朵闷闷的堵住的感觉是什么原因| 戊是什么生肖| 免疫性疾病是什么意思| beam是什么意思| 鼻子经常出血是什么病征兆| mom什么意思| 孕吐吃什么| mpd是什么意思| 高的部首是什么| 乳腺癌多发于什么年龄| 微创是什么| 小孩坐飞机需要什么证件| 1866年属什么生肖| 为什么要小心AB型血的人| 马的尾巴有什么作用| 大姨妈来了吃什么好| 咏柳中的咏是什么意思| 不屑一顾的意思是什么| 戏是什么生肖| 杏仁有什么作用| 四个鱼念什么| 蜈蚣怕什么东西| 为什么低血糖| 一月五日是什么星座| 吃海参有什么好处| 环比增长什么意思| b和o型血生的孩子是什么血型| 健康证检查什么| 狮子座是什么星座| edd什么意思| 摩羯男喜欢什么类型的女生| 什么样的人容易抑郁| 乙肝是什么病严重吗| 仕途是什么意思| 茯苓有什么作用| 1月22日什么星座| 蝉什么时候出现| 7月八号是什么星座| 三级警督是什么级别| 怀孕梦到老公出轨预示什么| 做梦梦到猪是什么意思| 恪尽职守什么意思| 懊恼是什么意思| 沱茶属于什么茶| 脑袋疼挂什么科| 什么不什么身| 小孩脱水有什么症状| 狐臭用什么药| 2017属什么生肖| 主播是什么意思| gravy是什么意思| 肛门周边瘙痒擦什么药| 皮肤过敏不能吃什么| 素心是什么意思| 脚真菌感染用什么药最好| 肩膀痛挂什么科| tj是什么意思| 百度Jump to content

Snapchat遭印度用户抵制 公司:我们CEO没说印度穷

From Wikipedia, the free encyclopedia
HTML 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.[1] 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 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

[edit]
Highlighting the effect of missing delimiter (after watch='false) in JavaScript

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.[2] 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

[edit]
gedit supports 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.[3] 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.[3]

Syntax elements

[edit]

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

[edit]

Below is a comparison of a snippet of C code:

Standard rendering Syntax highlighting
/* Hello World */
#include <stdlib.h>
#include <stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}
/* Hello World */
#include <stdlib.h>
#include <stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}

Below is another snippet of syntax highlighted C++ code:

// Create "window_count" Window objects:
const auto window_count = int{10};
auto windows = std::array<std::shared_ptr<Window>, max_window_count>{};
for (auto i = int{0}; i < window_count; ++i) {
    windows[i] = std::make_shared<Window>();
}

In the C++ example, the editor has recognized the keywords const, auto, int, and for. The comment at the beginning is also highlighted in a specific manner to distinguish it from working code.

History and limitations

[edit]

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.[4][5] 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,[6] which was used in the Intellivision's Entertainment Computer System (ECS) peripheral, released in 1983.[7] 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.[8] 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.[9] 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.[10]

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.[11] 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 results in very accurate understanding of code. An extension of syntax highlighting was called "semantic highlighting" in 2009 by David Nolden[12] 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,[13] and after that, the idea was transferred to other popular IDEs like Visual Studio,[14] Xcode,[15] and others.

Colour in a user interface is less useful if the user has some degree of colour blindness.

See also

[edit]

References

[edit]
  1. ^ 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.
  2. ^ Sarkar, Advait (2015). "The impact of syntax colouring on program comprehension". Proceedings of the 26th Annual Conference of the Psychology of Programming Interest Group: 49–58. Archived from the original on 24 September 2015. Retrieved 27 September 2023.
  3. ^ a b Oscar Rodriguez-Prieto; Alejandro Pato; Francisco Ortin (2025). "PLangRec: Deep-learning model to predict the programming language from a single line of code". Future Generation Computer Systems. 166 107640. Elsevier. doi:10.1016/j.future.2024.107640.
  4. ^ Hansen, Wilfred J. (1971). "User engineering principles for interactive systems". Proceedings of the Fall Joint Computer Conference FJCC 39. AFIPS. pp. 5623–532.
  5. ^ Hansen, Wilfred. "Emily - An Editor for Structured Text". Retrieved 17 June 2013.
  6. ^ Syntax error correction method and apparatus, 2025-08-05, retrieved 2025-08-05
  7. ^ Mattel Intellivision: Intellivision Computer Module Owner's Guide (1983)(Mattel)(US). 1983.
  8. ^ "Intellivision Classic Video Game System / Entertainment Computer System". www.intellivisionlives.com. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  9. ^ Cowlishaw, M. F. (1987). "LEXX – A programmable structured editor" (PDF). IBM Journal of Research and Development, Vol 31, No. 1, IBM Reprint order number G322-0151. IBM.
  10. ^ Allen, Dan (2025-08-05). "A Trio of Historical Recollections". mpw-dev (Mailing list). Archived from the original on 2025-08-05. Retrieved 12 September 2019.
  11. ^ "KEDIT Language Definition Files". Kedit. Mansfield Software Group, Inc. 2012. Retrieved 2025-08-05.
  12. ^ "2009 blog post on Semantic Highlighting introduced in KDevelop by David Nolden". 8 January 2009.
  13. ^ Brooks, Evan (17 April 2017). "2014 blog post on Semantic Highlighting by Evan Brooks". Medium.
  14. ^ "Visual Studio Magazine article on semantic highlighting".
  15. ^ "Github page of a plugin which implements semantic highlighting for Xcode". GitHub. 14 September 2022.
上海是什么省 头疼喝什么饮料 孕酮低吃什么 羊眼圈是什么 小孩子发烧抽搐是什么原因
2月出生是什么星座 股票加杠杆是什么意思 门户网站是什么 贵州有什么好玩的 山药和淮山有什么区别
利福平是什么药 锌过量会引发什么症状 冷暖自知上一句是什么 口嫌体正直什么意思 突然手发抖是什么原因
北极熊是什么颜色的 居士是什么意思 胃溃疡吃什么食物 妇科病是什么 movefree是什么药
悟性是什么意思beikeqingting.com 天公作美什么意思hcv9jop1ns0r.cn 吃什么可以缓解痛经hcv7jop6ns7r.cn 马来酸曲美布汀片什么时候吃bjhyzcsm.com 劲爆是什么意思sanhestory.com
重庆以前叫什么hcv8jop8ns2r.cn 掉发是什么原因hcv7jop9ns7r.cn 不10是什么意思hcv8jop2ns4r.cn 胃疼吃什么药hcv7jop5ns1r.cn 前白蛋白低是什么意思hcv9jop6ns1r.cn
男人为什么喜欢大胸hcv9jop1ns3r.cn 破产是什么意思hcv8jop2ns8r.cn 肩袖损伤用什么药xinmaowt.com 人为什么会梦游tiangongnft.com 普贤菩萨的坐骑是什么zsyouku.com
为什么会长水泡hcv7jop9ns2r.cn 什么食物防辐射hcv9jop1ns9r.cn ns什么意思hcv7jop6ns2r.cn 护理是什么hcv9jop0ns7r.cn 化学性肝损伤是指什么hcv7jop6ns3r.cn
百度