Sublime Forum

Weak Code Folding - A request for improved, less buggy folding


Hello! I absolutely adore Sublime Text 3. I was happy to pay for this editor and recommend it to my colleagues. Powerful package management, loads of addons, highly customizable, beautiful out of the box, insanely light weight and responsive - one thing is seriously letting me down though and that is code folding and I’ve found dozens of forum posts with similar complaints.

I struggle to understand how this implementation of code folding is useful for anybody and I suspect that many people don’t actually use it or don’t know about it. Here are my concerns with this feature:

  1. There is an “unfold_all” feature, but no “fold_all” feature for no obvious reason. I would expect this to allow me just to collapse everything inside of everything (recursively) and expand it out as required to narrow down a portion of code from the top-down easily. Why isn’t this a feature?
  2. The CTRL + K, 1-9 feature is unintuitive. It seems to be collapsing by indentation, instead of syntax. Unless code folding was intended for strongly indented languages like Python; why isn’t folding syntax-specific?
  3. The collapse toggle buttons are hidden by default. This is a mistake in my opinion as your mouse needs to be in the left-side gutter before they even appear. If shown all the time by default, they serve as a useful visual aid to identify where code blocks begin.
  4. I am aware of the “fold current block” and “unfold current block” options but if you have to focus on every block you want to fold in the first place, what’s the point in folding at all?

Geany has the upper hand on this one in almost every way possible:

  • The + / - buttons are visible all the time so you don’t need to guess where your mouse needs to land.
  • A stronger visual aid showing where the a folded section hides.
  • Nesting indicators in the vertical gutter to any depth showing where blocks start and terminate.
  • Shortcuts for “Fold All” and “Unfold All” by default. These actions are recursive, allowing for top down code traversal without noise (the entire point of code folding).
  • Fold states of inner code are remembered after these shortcuts are fired, so you can switch between folded sections whilst retaining a focus on inner blocks of interest.

The only feature Geany lacks is a “fold to level” shortcut like CTRL + K,3 for example. This point is moot though, as Sublime Text 3 isn’t even recognizing the nested inner if-statement in this case because it only contains a comment.

Additionally, the “Unfold All” feature does not work with this example. Folding all, and then selecting “Unfold All” from the Edit menu does absolutely nothing.

In all of my projects (C#, PHP, Laravel, Python, Bash) this is the most impacting feature issue I experience. I don’t understand why this isn’t a bigger issue. Either people aren’t actively using code-folding that much for it to be raised as a problem or I am completely missing the proper usage of code folding in Sublime.

Please have a look at beefing up the Code Folding feature for my Christmas. It would make me a very happy developer. :slightly_smiling:

Edit: For completeness, here are the settings I use:

    "auto_find_in_selection": true,
    "bold_folder_labels": true,
    "caret_style": "phase",
    "fade_fold_buttons": false,
    "font_face": "Ubuntu Mono",
    "font_size": 11,
    "highlight_line": true,
    "line_padding_bottom": 1,
    "line_padding_top": 1
1 Like


yeah, the first thing I do is set "fade_fold_buttons": false, in my user preferences :wink:

maybe add your vote to these as you see fit:

1 Like


Hi kingkeith! Yes. This is a good UI preference and should be default IMHO. I have updated my original post to include my custom settings definitions. Thanks for your feedback. :slight_smile:



The issue here is that it’s only a single line, not that this line is a comment specifically.