Sublime code folding of comments (as in Ace)

2019-05-21 07:08发布

问题:

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?

回答1:

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



回答2:

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.



回答3:

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