{"id":242472,"date":"2023-04-21T09:00:34","date_gmt":"2023-04-21T16:00:34","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/visualstudio\/?p=242472"},"modified":"2023-04-21T11:21:05","modified_gmt":"2023-04-21T18:21:05","slug":"improving-the-syntax-highlighting-of-javascript-in-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/improving-the-syntax-highlighting-of-javascript-in-visual-studio\/","title":{"rendered":"Improving the Syntax Highlighting of JavaScript in Visual Studio"},"content":{"rendered":"<p>Syntax highlighting, aka colorization, is one of Visual Studio&#8217;s essential features; it uses colors and styles to help guide our brains when reading code. Following <a href=\"https:\/\/developercommunity.visualstudio.com\/t\/Please-improve-the-syntax-highlighting-f\/10150854\">this Developer Community suggestion<\/a>, we decided to work on improving the JavaScript and TypeScript experience!<\/p>\n<p>Starting from 17.6 we improved existing colorization and expanded it to new areas including control keywords, strings in tags, escape characters, JSDocs, and more.<\/p>\n<p>This post walks you through these changes and how you can configure and personalize your own!<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242473 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/banner.png\" alt=\"Banner displaying a side by side meaningless source code\" width=\"624\" height=\"139\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/banner.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/banner-300x67.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2>Overview<\/h2>\n<p>Syntax highlighting is a Visual Studio feature that differentiate various parts of the code according to their meaning, such as keywords, variables, and comments. This makes your code easier to read and understand by visually distinguishing the elements of the source code.<\/p>\n<p>To increase the efficiency of your code maintenance, we have remapped the TypeScript and JavaScript source code into new <em>Display items<\/em>. With this change, Visual Studio is now able to apply more granular styles and higher personalization. You can read more about <em>Display items<\/em> <a href=\"#personalize-the-syntax-highlighting\">here<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<h2>Examples<\/h2>\n<p>Look at these screenshots from before and after this change:<\/p>\n<ul>\n<li>Control keywords are mapped to the <em>Keyword \u2013 Control <\/em>display item<em>.<\/em><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242490 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample-1024x530.png\" alt=\"Before and after comparison of the new syntax highlight of control keywords\" width=\"640\" height=\"331\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample-1024x530.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample-300x155.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample-768x398.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample-1536x795.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/keywords_sample.png 1982w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>Types are mapped to the <em>Type <\/em>display item<em>.<\/em> You can also distinguish between HTML tags and React components!<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242495 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample-1024x132.png\" alt=\"Before and after comparison of the new syntax highlight of types\" width=\"640\" height=\"83\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample-1024x132.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample-300x39.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample-768x99.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample-1536x198.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/types_sample.png 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>Variables are mapped to the <em>User Members \u2013 Locals <\/em>display item<em>. <\/em>You can distinguish them better inside JSX as well, check <em>{count}<\/em> for example!<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242496 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample-1024x336.png\" alt=\"Before and after comparison of the new syntax highlight of variables\" width=\"640\" height=\"210\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample-1024x336.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample-300x98.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample-768x252.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample-1536x504.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/variables_sample.png 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>Escape characters are mapped to the <em>String \u2013 Escape Character <\/em>display item<em>, making them distinguishable when within a string.<\/em><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242491 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample-1024x71.png\" alt=\"Before and after comparison of the new syntax highlight of escape characters\" width=\"640\" height=\"44\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample-1024x71.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample-300x21.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample-768x53.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample-1536x106.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/escape_sample.png 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>Parameter names are mapped to the <em>User Members \u2013 Parameters<\/em> display item<em>. <\/em>Values are assigned with their correct classification as well!<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242494 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample-1024x401.png\" alt=\"Before and after comparison of the new syntax highlight of parameter names\" width=\"640\" height=\"251\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample-1024x401.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample-300x118.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample-768x301.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample-1536x602.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/parameter_sample.png 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>Methods are mapped to the <em>User Members \u2013 Methods <\/em>display item<em>.<\/em><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242493 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/methods_sample-1024x375.png\" alt=\"Before and after comparison of the new syntax highlight of methods\" width=\"640\" height=\"234\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/methods_sample-1024x375.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/methods_sample-300x110.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/methods_sample-768x281.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/methods_sample.png 1522w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<ul>\n<li>JSDoc tags are mapped to the <em>Keyword <\/em>display item<em>.<\/em><\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone wp-image-242492 size-large\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample-1024x207.png\" alt=\"Before and after comparison of the new syntax highlight of JSDoc reserved words\" width=\"640\" height=\"129\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample-1024x207.png 1024w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample-300x61.png 300w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample-768x155.png 768w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample-1536x310.png 1536w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/jsdoc_sample.png 1980w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h2><a id=\"personalize-the-syntax-highlighting\"><\/a>Personalize the syntax highlighting<\/h2>\n<p>All the different parts of the source code are mapped to a <em>Display item\u00a0<\/em>that defines the style of the editor. Visual Studio provides an effortless way to personalize them.<\/p>\n<p>To access these settings, go to <em>Tools &gt; Options &gt; Environment &gt; Fonts and Colors<\/em> and select <em>Text Editor <\/em>from the <em>Show settings for<\/em>\u00a0dropdown. Select the <em>Display item<\/em> and set the <em>Item foreground, Item background, Font, <\/em>and <em>Size <\/em>to the options you want.<\/p>\n<p>For example, if you want variables to be <em>White,<\/em> you can choose the display name <em>User Members \u2013 Locals <\/em>and change the <em>Item foreground<\/em> to <em>White<\/em>:<\/p>\n<h2><img decoding=\"async\" class=\"alignnone wp-image-242479 size-full\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/settings.png\" alt=\"Options window displaying an example of how to customize the variables color\" width=\"624\" height=\"235\" srcset=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/settings.png 624w, https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2023\/04\/settings-300x113.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/h2>\n<p>&nbsp;<\/p>\n<h2>Let us know what you think!<\/h2>\n<p>We hope you like the new experience. If you found an issue or would like to suggest a change, follow this link to <a href=\"https:\/\/developercommunity.visualstudio.com\/VisualStudio\">Visual Studio Feedback<\/a> and fill out a feedback ticket. We will be happy to hear about it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Syntax highlighting, aka colorization, is one of Visual Studio&#8217;s essential features; it uses colors and styles to help guide our brains when reading code. Following this Developer Community suggestion, we decided to work on improving the JavaScript and TypeScript experience! Starting from 17.6 we improved existing colorization and expanded it to new areas including control [&hellip;]<\/p>\n","protected":false},"author":117081,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155,1029],"tags":[124,185,125,12],"class_list":["post-242472","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","category-web","tag-javascript","tag-node-js","tag-typescript","tag-visual-studio"],"acf":[],"blog_post_summary":"<p>Syntax highlighting, aka colorization, is one of Visual Studio&#8217;s essential features; it uses colors and styles to help guide our brains when reading code. Following this Developer Community suggestion, we decided to work on improving the JavaScript and TypeScript experience! Starting from 17.6 we improved existing colorization and expanded it to new areas including control [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/242472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/117081"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=242472"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/242472\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=242472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=242472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=242472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}