Using the last line of a code block to fold it

Display customization and font issues

Using the last line of a code block to fold it

Postby tomek » Fri Apr 09, 2010 11:43 am

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
User avatar
tomek
Newbie
 
Posts: 9
Joined: Fri Mar 11, 2005 12:00 am

Re: Using the last line of a code block to fold it

Postby Mofi » Fri Apr 09, 2010 4:53 pm

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.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3936
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Using the last line of a code block to fold it

Postby tomek » Fri Apr 09, 2010 4:59 pm

Thanks a lot Mofi, this will be very helpful!
User avatar
tomek
Newbie
 
Posts: 9
Joined: Fri Mar 11, 2005 12:00 am


Return to Editor Display