[Lazarus] Live Templates

Martin Friebe lazarus at mfriebe.de
Wed May 13 16:30:45 CEST 2009


Mattias Gärtner wrote:
> Zitat von Lee Jenkins <lee at datatrakpos.com>:
>   
>> Graeme's recent post made me wonder if there is been work or talk of work on
>> implementing Live Templates like Delphi has?
>>     
> Yes.
>
> 1. Lazarus will not support the Delphi syntax, because Lazarus already  
> supports code macros. There are already some code macros using the  
> codetools.
>
> 2. auto complete without pressing a short cut already works for  
> return, space and word end.
> Some code macros are needed to fine tune adding text if parts of the  
> template already exists (for example auto complete 'begin' after  
> pressing return). But this is stuff for another thread.
>
> 3. templates with parameters: editing the parameters directly in the  
> source editor (synedit) without a dialog. synedit needs a further edit  
> mode for marking and editing several places in parallel. Martin has  
> already implemented marking several places. I guess he can also create  
> a plugin/extension/mechanism for the needed edit mode. When this is  
> done, I will be glad to implement the rest.
> This edit mode is also needed for in situ rename.
>   
Yep, it's on the list, but not yet sure when.
For code Template there a 2 main targets:
1) "Form mode"
- The code template defines several places (form-fields) where input is 
needed "for [] := [] to [] do"
- the Editor the allows to navigate them using tab (or a user defined 
key shortcut

2) Sync Edit
Actually this is a feature off it's own, but should work specially with 
templates: the form-fields from above could be linked, editing the 
content off 1, would update the other too.

Example: check a variable is in range: (while you type in field 1, the 
same appears in field 2:
"if ([] >= 10) and ([] < 20) then "

>   
>> I imagine that that kind of behavior is a bit of work to implement.
>>     
>
> Yes, but I bet Martin has already some ideas for synedit.
>   

Not exactly related to templates, but one feature, I like to add for myself.

Motivated by commenting code.
If you type "(*", this will comment all of the remaining code, 
temporarily disabling all highlighting, and unfolding everything.....

A magic "add cloisng bracket".

If you type "(*" SynEdit inserts a >virtual< "*)". (Could be shown like 
a hint...) the closing "*)" follow sthe caret movement.
So you can move the caret to the desired location and hit enter.
It could be cancelled bey "esc", it would also detect manually typing 
the "*)" sequence....

It could work for any other pair-construct, including begin/end





More information about the Lazarus mailing list