Code folding in Komodo Edit

I am using Komodo Edit 8.5.4 to edit Perl code and there are some things I would like to do with code folding that I use in other editors (e.g. NotePad++):

  1. It would be convenient if comment blocks (i.e. consecutive lines that only have comments) could be folded.
  2. Currently when a section of code is folded it folds (i.e. hides) the blank lines following the code block. It would be convenient to have an option to exclude trailing blank (i.e. only containing whitespace) lines from a folding section.
  3. It would be nice to be able to fold all code and comment sections up to the level of ones choice, rather than fold all levels (i.e. depths). For example, one might want to fold all subroutines within a selected block of text, but not the code blocks within the subroutines (in NotePad++ this is code folding at only the first level). I’m not suggesting that it be aware of the distinction between subroutines and other code blocks, only that all code blocks and comments within a selection be foldable to a depth of ones choice.

Does anyone know of a way to customize Komodo Edit to have one or more of these behaviors, or how one might submit a feature request to the Komodo development team?

Hey @jkollar,

You can file enhancement requests by using this link to the Komodo bug tracker or use Help > Troubleshooting > Report Bug. You would file it as an enhancement request.

Customizing this is possible but it’s buried in C++ code in Scintilla. We have a custom Lexer file for Perl. I’ve found the function that does the folding, if you’re interested, here: https://github.com/Komodo/KomodoEdit/blob/master/contrib/scintilla/lexers/LexPerl.cxx#L1560

You’re best bet is to file an enhancement request if you don’t want to compile Komodo from source.

  • Carey

Thanks, careyh.

I will submit my enhancement suggestions through the bug tracker, as you suggested.

Hey thanks! Can you post it here when you’ve created it?

The bug number is 106175.

Just starting to look at Kom-IDE as a substitute for BBEdit when I have to work in Linux. The code folding for bash isn’t particularly useful. It only seems to fold comments the way the OP mentions in #1.

Hi there,
is there anything new about this subject? I hope it is ok, that I continue such an old topic. I am using the trial version of Komodo 10 right now and I really like it so far, but this here could be the “deal breaker” for me. I have PHP files with thousands of lines and dozens of functions and I need a functionality, that allows me to auto-fold the code on a “function-level” (when I open a file, all functions are folded, but nothing else). Is there any way?
Thanks a lot!

Hi,

Komodo does not have a built-in option to open a file with folds collapsed, but you could set up a userscript that does this automatically for you. (It will not differentiate between functions and other fold elements though.)

  1. Open the Toolbox in the right pane.
  2. Right click inside it and select Add > New Userscript…
  3. Name the userscript and add the following line: require('ko/editor').scimoz().foldAll(0).
  4. Click on the Triggers tab in the dialog.
  5. Check the checkbox.
  6. Verify the After File Open option is selected.
  7. Click Ok.