Tapatalk

Collapsing only the first level

Collapsing only the first level

1
NewbieNewbie
1

    Jul 01, 2016#1

    Line folding does a marvelous job, but my preference is to collapse only the primary, first level sets of matches. In order to do that, when a file is loaded, I expand all folds then go through it to collapse only the primary folds one-at-a-time. Some of the files are around 5,000 lines handling a large number of jQuery elements, functions and code structures. Is there a means to only collapse the primary, outer, non-indented sets of matches? For example, I would want to collapse a block of code like a function or a jQuery element, but nothing inside that function or element.

    115
    Power UserPower User
    115

      Jul 01, 2016#2

      This is not possible. The way code folding works in UE is that when the file is processed each time an Open Fold value is found, it is paired with the next Close Fold value found. When multiple Open Fold values are found, they are matched in last-in, first-out order. UE doesn't know anything about at what level it finds the values. It doesn't even care if the Open Fold value matches the Close Fold value you wanted, only that it has found one of each.

      6,685587
      Grand MasterGrand Master
      6,685587

        Jul 01, 2016#3

        This is not possible with any built-in command. But it could be done using a macro.

        For example with Show last line of fold in syntax highlighted files enabled and the opened file is a C source code file and all most outer { ... } blocks should be folded, a very simple macro code for this task would be:

        Code: Select all

        InsertMode
        ColumnModeOff
        HexOff
        UnixReOff
        Top
        Loop
        Find MatchCase "{"
        IfFound
        Key LEFT ARROW
        HideShowSelection
        Key DOWN ARROW
        Else
        ExitLoop
        EndIf
        EndLoop
        
        This is just a very simple example. The macro must be coded to be smart enough to avoid wrong folds which means it must be specialized for a specific language (language intellisense).
        Best regards from an UC/UE/UES for Windows user from Austria