Using the last line of a code block to fold it

Using the last line of a code block to fold it

9
NewbieNewbie
9

    Apr 09, 2010#1

    When working with an old Perl script I realized that it would be very useful if one could be able to fold a code block
    by initiating the folding from the last line of the block. From what I have been able to find out so far one can easily
    fold a code block when one can see the block first line as in:

    Code: Select all

      if (xxxxxxx) {
      .
      .
    but quite often you see just the last part:
      .
      .
      }
    and the only way to fold the block in that case is to first, find the first line of the block and only then, fold the whole thing.
    :?: Do you know whether UE allows one to fold code by using the last line of a block?

    Another way of accomplishing the same would be a function to jump to the "matching brace" but I have not been able to find out
    if that is possible either, :?: is it?

    Tomasz

    6,603548
    Grand MasterGrand Master
    6,603548

      Apr 09, 2010#2

      That's no problem. There is the command Search - Match Brace which works also upwards and selects everything from closing } to matching {. This command is also available as macro or script command. Therefore you can for example use following macro to fold a block when cursor is at end of a block.

      MatchBrace
      Key HOME
      HideShowSelection

      Just create a new macro with a hotkey or chord with these 3 lines and save the macro into a macro file (together with other macros) which is specified to be automatically loaded on startup of UltraEdit and you can always quickly fold a block with cursor on end of a block by pressing the hotkey or chord.
      Best regards from an UC/UE/UES for Windows user from Austria

      9
      NewbieNewbie
      9

        Apr 09, 2010#3

        Thanks a lot Mofi, this will be very helpful!