kye
kye

Reputation: 56

Sublime code folding of comments (as in Ace)

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?

Upvotes: 3

Views: 1403

Answers (4)

Alex Sz&#252;cs
Alex Sz&#252;cs

Reputation: 681

Comment folding works if content is a bit deeper. Instead of this

/*
line 1
line 2
line 3
*/

use:

/*
    line 1
    line 2
    line 3
*/

Upvotes: 0

Tuhin Sengupta
Tuhin Sengupta

Reputation: 59

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

Upvotes: 4

neaumusic
neaumusic

Reputation: 10474

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

Upvotes: 0

zkent
zkent

Reputation: 980

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.

Upvotes: 0

Related Questions