VSCode中CSS的代码折叠 [英] Code Folding for CSS in VSCode
问题描述
我无法折叠代码以在Css的编辑器中工作。在html和js中,我都可以根据注释折叠代码,这使我可以创建整洁的组。但是在CSS中,您无法折叠评论。有谁知道一种方法来启用此功能或另一个在Css文件中创建代码组的不错的技巧?这是一些图片。
I can't get code folding to work in the editor in Css. In both html and js I can fold code according to comments, which enables me to create neat groups. But in Css you can't fold comments. Does anyone know of a way to enable this or another nice tip for creating groups of code in a Css file? Here are some pictures.
在这里您可以看到自己的班级注释旁边没有减号按钮:
Here you can see there is not minus button next to the Own Classes comment:
但是在这里您可以看到注释在js中很好地折叠,这使我能够创建漂亮的代码组:
But here you can see the comments fold nicely in js, this enables me to create nice groups of code:
推荐答案
请参见文档了解有关VS Code中的代码折叠的信息:
See the docs to read about code folding in VS Code:
自1.22版本以来,foldi ng范围也可以根据编辑者配置的语言的
语法标记来计算。以下
语言已经提供了可识别语法的折叠:
Since the 1.22 release, folding ranges can also be computed based on syntax tokens of the editor's configured language. The following languages already provide syntax aware folding:
Markdown,HTML,CSS,LESS,SCSS和JSON
Markdown, HTML, CSS, LESS, SCSS and JSON
CSS / Less / SCSS: / *#region * /
和 / *#endregion * /
CSS/Less/SCSS: /*#region*/
and /*#endregion*/
< img src = https://i.stack.imgur.com/Q5vGL.png alt =在此处输入图片描述>
默认情况下,CSS应启用基于语法的代码折叠。您可以使用以下设置切换回使用缩进CSS:
So your code folding based on syntax should be activated by default for CSS. You can switch back to using indentation for CSS with the following setting:
"[css]": {
"editor.foldingStrategy": "indentation"
},
这篇关于VSCode中CSS的代码折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!