What is Syntax Highlighting?

 Text files written in programming or markup languages can be daunting to read and edit, especially when your text editor displays it all in endless lines of small, black text.

Syntax highlighting is a feature of many text editors that color-codes text in programming/markup languages according to the categories of that language. For example, in an HTML file, all elements of a certain type might be colored blue, while those of another type might be green.

Syntax highlighting makes it much easier to read and write in structured languages since syntax errors and other elements become visually distinct with color-coding. This feature is solely for the aid of human editors, since it does not affect the meaning if the text in any way. Highlighting improves readability without altering the text itself.

Some of the staple syntax highlighting functions include brace matching, which locates and highlights matching or missing opening and closing tags, and highlighting string literals, which makes spotting delimiter errors much easier.

Text editors that only support one language will highlight according to that language's rules. For text editors that support multiple languages, the text editor determines how to highlight based on the file extension or by detecting the language through scanning the file. Since these methods are automatic, files that contain multiple languages, or unrecognized languages can cause errors in the highlighting.

For this reason, some text editors with syntax highlighting allow you to customize your syntax highlighting preferences by specifying keywords, start and end tags, etc. Additionally, some languages and text editors support language-specific highlighting of text embedded within text written in a different language. For example, embedding JavaScript inside HTML causes the program to recognize and highlight both languages correctly.

Syntax highlighting is an important feature for text editing, and finding the text editor that supports your highlighting preferences can greatly improve your text editing skills and experience.