collapse python在vs代码中的评论
不久前,我开始在Python中评论很多代码,问题是VS代码并没有为我提供减少评论。
我尝试过单行评论和组评论,但同一问题。
例如,其他语言为例如级。 collapse
在vs中如何启用注释崩溃?
Not long ago, I started commenting a lot of code in python, the problem is that vs code does not offer me to reduce the comment.
I have tried single line comments and group comments but same issue..
python single line comment
python multiline program
In other languages for example C.. it offers me in the bar a button to collapse
How can comment collapsing be enabled in VS?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(3)
我尝试了。我认为VSCODE本身提供了此功能,但是我不知道为什么它不适合您。
从图可以看出,可以折叠多元注释。
当然,您的情况没有解决方案。我们可以在内容之前添加
#Region
,在内容之后添加#endregion
。I tried it. I think vscode itself provides this function, but I don't know why it doesn't work for you.
As can be seen from the figure, multiline annotations can be folded.
Of course, there is no solution for your situation. We can add
#region
before the content, add#endregion
after it.我遇到了同样的问题。
在大多数情况下,Mingjie-Msft的解决方案告诉您您的工作状况会很好。
但是,如果它仍然不起作用,那么我发现的另一种解决方案可能会起作用。尝试一下。
该解决方案是再次缩进所有线路,它们位于多行操作员之间。
以下示例将使您理解更容易。
I had the same problem.
In most cases, the solutions MingJie-MSFT told you will work well.
However, if it still does not work, then another solution which I found might work. Try this.
This solution is to indent all lines once again, which are between the multi-line-comments-operator.
The following example will make you understand easier.
实际上,我刚刚制作了一个VS代码扩展程序来解决此确切的问题:
它可以折叠python中连续的单行注释(以及其他语言,例如Ruby,Shell和YAML)。为此,它实现了一个折叠式的程序,该折叠式提供者检测以“#”开头的线序列:
当前,它不会将空行计算为可折叠区域的一部分,这与VS代码如何正式支持JavaScript/Typescript的单个单曲单词 -行评论,但我个人认为这样会更好。我不确定是否有足够的需求将其切换为否则/将其设置为默认设置。
该扩展名可以自动启用连续单行注释的折叠,您可以单击“排水沟”中的折叠图标(如在C示例中)以折叠/展开它们。
这是一张图片,显示了带有python代码的天沟。
- 线评论。当前没有“展开的单线评论”,但不应该太难添加。官方展开的所有命令将与此作用,因为我们只是将单线评论作为可行的折叠区域。
这就是该命令的样子。
I actually just made a VS Code extension to solve this exact problem: Fold Single-Line Comments
It enables folding for consecutive single-line comments in Python (and other languages like Ruby, Shell, and YAML). To do this, it implements a FoldingRangeProvider that detects sequences of lines starting with '#':
Currently, it not will count empty lines as part of a foldable area, which is different from how VS Code officially supports it for JavaScript/TypeScript's single-line comments, but I personally thought it would be better that way. I'm not sure if there's enough demand to toggle it otherwise/set it as the default.
The extension automatically enables folding for consecutive single-line comments, and you can click the folding icon in the gutter (like in your C example) to collapse/expand them.
Here's a picture showing the gutter with Python code.
Here's how they look when folded.
You can also use the command "Fold Single-Line Comments" from the command palette to specifically fold only those single-line comments. There is currently no "Unfold Single-Line Comments," but it should not be too hard to add. The official Unfold All command will work with this, because we've simply consecutive single-line comments as viable folding areas.
Here's what that command looks like.