Sublime Forum

How do I expand a section of code I accidentally collapsed?

#1

Hi, I accidentally collapsed some code with the little down arrow that appears in the left margin. It now shows a little yellow thing next to the line of collapsed code.

When I double-click on it, however, it won’t expand the code, instead it highlights the yellow icon and the bracket next to it as though I’m selecting text. I’ve tried and tried to expand it by clicking on it over and over, but can’t!

The cursor always appears as an I-bar even when hovering over that little icon, so ST seems to think it’s text. How in the world do I expand it again? Is there some command that will expand ALL code in the document? Thanks!

0 Likes

#2

The yellow folded text icon you see is a placeholder for the folded away text and is treated as such; for example you can backspace over it to delete all of the folded text in one shot.

If you folded the text by using the arrow icon in the gutter, that icon changed from an arrow that points downwards to one that points rightwards; clicking that icon again will unfold the code. Depending on your settings, you may have to hover the mouse over the gutter to get the fold icons to appear.

You can also use the menu item Edit > Code Folding > Unfold or the associated key binding (visible in the menu) to unfold the text as well, or use Edit > Code Folding > Unfold All to unfold everything at once.

1 Like

#3

Of course! Not sure why I didn’t think of trying those little down arrows in the margin again. They only appear when the cursor hovers over the margin, so it was out of sight, out of mind. But once I hovered over the margin, the arrow appears again, pointed to the right, so I just clicked that and it expanded. Duh! :slight_smile:

Also good to know those Folding menu options are there, thanks very much!

1 Like

#4

If you tend to work with folding a lot (or otherwise want to be reminded), the fade_fold_buttons setting can make the fold icons always appear.

    // Hides the fold buttons unless the mouse is over the gutter
    "fade_fold_buttons": true,

As seen here, the default is to hide the fold icons except when you explicitly hover to obtain them, but setting this to false in your user preferences will make them always be there.

1 Like

#5

Great tip @OdatNurd !
I was looking for something like this since I use folding a lot to edit large JSON files.

0 Likes