Sublime code folding of comments (as in Ace)

2019-05-21 07:04发布

In Cloud9 (based on the Ace editor) I can define arbitrary code folding regions within comments, for example:

// Descriptor {
function() {

    // Code

}
// }

Folds to:

// Descriptor {<->}

Try it here to see what I mean.

Is there an existing way to replicate this in Sublime?

3条回答
老娘就宠你
2楼-- · 2019-05-21 07:32

Yes, you use CMD+K+1 to fold at level 1, CMD+K+2 for level 2, etc CMD+K+J will unfold all CMD+OPT+[ will fold / hide the current level of indendation, CMD+OPT+] will unfold any of the yellow rectangle symbols at the end of a line

查看更多
We Are One
3楼-- · 2019-05-21 07:37

Select the block of code and Hit "Ctrl + Shift + [" to fold. To unfold place pointer before the folded block and hit "Ctrl + Shift + ]"

here's an youtube video link: https://www.youtube.com/watch?v=80UUPMUAP-g

查看更多
叛逆
4楼-- · 2019-05-21 07:42

From http://wesbos.com/sublime-text-code-folding/

To fold a block, place your cursor anywhere within the block you want to fold. Now you just hit the folding keys to collapse that block.

Command + Option + [

The thing you will have to remember is that Sublime Text's folding mechanism is dependent on code intention levels and not scope.

查看更多
登录 后发表回答