{"id":260,"date":"2023-12-13T18:22:31","date_gmt":"2023-12-13T18:22:31","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=260"},"modified":"2023-12-19T21:34:40","modified_gmt":"2023-12-19T21:34:40","slug":"region-folding-in-vs-code","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/region-folding-in-vs-code\/","title":{"rendered":"Region Folding in VS Code"},"content":{"rendered":"\n<p>VS Code has code folding already, of course. Almost any logical bit of code is foldable. A CSS ruleset, a JavaScript function, a nested bit of JSON, any HTML element with children, etc. <\/p>\n\n\n\n<p>But if you want to make a <em>custom section<\/em> of code foldable, you can<a href=\"https:\/\/code.visualstudio.com\/docs\/editor\/codebasics#_folding\"> wrap in special code comments<\/a> like this:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-comment\">\/* #region *\/<\/span>\n<span class=\"hljs-comment\">\/* #endregion *\/<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<!--more-->\n\n\n\n<p>Those are valid comments in CSS and JavaScript, but not all languages, so the syntax tends to follow whatever normal comments are in that language. HTML is:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-comment\">&lt;!-- #region --&gt;<\/span>\n<span class=\"hljs-comment\">&lt;!-- #endregion --&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>You can also put extra text after those keywords if it&#8217;s helpful to have their name be visible after you&#8217;ve folded, like <code>&lt;!-- #region FooterStuff --&gt;<\/code>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/assets.codepen.io\/3\/folding.gif?ssl=1\" alt=\"\" style=\"width:447px;height:auto\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>VS Code has code folding already, of course. Almost any logical bit of code is foldable. A CSS ruleset, a JavaScript function, a nested bit of JSON, any HTML element with children, etc. But if you want to make a custom section of code foldable, you can wrap in special code comments like this:<\/p>\n","protected":false},"author":1,"featured_media":262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[44,43],"class_list":["post-260","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-code-folding","tag-vs-code"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2023\/12\/folding-thumb.jpg?fit=1000%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":3,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":298,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions\/298"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/262"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}