Sublime Text:隐藏所有代码并仅显示注释 [英] Sublime Text: Hide all code and show only comments
问题描述
在Sublime Text 3中管理非常大的样式表很麻烦。
I find it tedious to manage very large style sheets in Sublime Text 3.
我的某些样式表大约有2000行代码。我试图弄清楚如何在样式表中更轻松地导航。我已经了解书签和出色的搜索功能,但是另一种方法是隐藏/折叠所有代码并仅显示注释。这样可以更轻松地找到您要去的正确位置。
Some of my stylesheets are about 2000 lines of code. I am trying to figure out how to navigate more easily within the stylesheet. I already know about bookmarks and the brilliant search function, but another way would be to hide/fold all code and show comments only. Tis way it would be easier to find the correct place you want to go to.
那么有没有办法将所有代码隐藏在注释下方?这与折叠评论
So is there a way to hide all code below a comment? This would be something as the opposite of Fold Comments
我知道 Hugo 提出了经典的全部折叠解决方案此处。但是我想完全隐藏所有代码并仅显示注释。
I know Hugo proposed the classic "fold all" solution here. But I would like to hide absolutely all code and display comments only.
例如:
/*******************************************************************
Description 1
*******************************************************************/
Hide/fold all code between here...
...
...
..
.
.
/*******************************************************************
Description 2
*******************************************************************/
推荐答案
您可以折叠所有内容,即打开控制台 ctrl +`
并输入 view.fold(view.find_by_selector(-comment))
。
这将使用选择器-注释
搜索所有区域,这意味着除注释之外的所有内容。然后将这些区域折叠起来。
You can fold everything, which is not a comment by opening the console ctrl+`
and write view.fold(view.find_by_selector("-comment"))
.
This searches all regions with the selector - comment
, which means everything except comments. Afterwards these regions are folded.
如果要为其创建键绑定,只需创建一个插件即可。打开工具>>>开发人员>>>新插件
并粘贴:
If you want to create a keybinding for it, just create a plugin. Open Tools >>> Developer >>> New Plugin
and paste:
import sublime_plugin
class FoldEverythingExceptCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
regions = self.view.find_by_selector("-comment")
self.view.fold(regions)
然后将其添加到您的键绑定-用户
为命令添加键绑定:
Afterwards add this to your Key Bindings - User
to add a keybinding for the command:
{
"keys": ["ctrl+alt+shift+f"],
"command": "fold_everything_except_comments"
},
这篇关于Sublime Text:隐藏所有代码并仅显示注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!