Code Templates - Single letter shortcut, alphabetical ordering, semicolon, slow lazarus / 21-General ---------------------------------------------------------------------- 741 · 2024-02-04 14:38 Lazarus 2.2.6 (rev lazarus_2_2_6) FPC 3.2.2 x86_64-win64-win32/win64 Code Templates readily allow me to add (for example) a template with a single-character shortcut like "a" or "b". So far this is like Delphi. I want to define a begin...else statement without an 'else', and my desired shortcut is "b". So I add a token "b" - that is because it is faster to type "b" than typing in a longer string. Then the template is defined. begin    | end; The template is saved OK (it can be seen in the Code Template editor) - but it does not (seem to) appear in the list when I use CTRL+J... ...Further slow, manual scrolling reveals that the "b" template has been added in-between "withb" and "withs". Next I do the same thing, with the token "bb". This time, the entry gets appended to the very end of the list. I'd expect the pop-up list to sort alphabetically... in fact I have to scroll all over the list to find what I want. All these things mean that it is not the "great time saver" (https://wiki.freepascal.org/IDE_Window:_Code_Templates) it was in Delphi. It used to be I typed CTRL+J b and that produced the template I added for "b". That was a time-saver.  No longer. I type CTRL+J b, then scroll through the entire list. BTW: I notice that the default entries use $AddSemicolon()  rather than ';', I am not sure if that matters? ---------------------------------------------------------------------- jamie · 2024-02-04 14:55 Most likely due to the fact its a text file and must be searched each time. That system should be a compiled bin file with an index header that points to the complete definition or the complete result string. ---------------------------------------------------------------------- Martin_fr · 2024-02-04 15:00 Indeed if you open the list (ctrl-j) before typing any letter (that is the cursor is after a space or at BOL) then - the full list pops up - it seems not sorted - it does not filter if you start typing. That probably could be improved => report it as an issue (it still happens in 3.99) You can however: type b and then ctrl-j  => as be is a 100% match, the list will not even open, it will complete directly. Until then, you can enable code templates to be shown with ctrl-space among the completion proposals. And that makes them easier to access. ---------------------------------------------------------------------- J-G · 2024-02-05 11:57 Quote from: 741 on February 04, 2024, 03:38:55 pmI want to define a begin...else statement without an 'else', and my desired shortcut is "b". So I add a token "b" - that is because it is faster to type "b" than typing in a longer string. Then the template is defined. I regularly use this facility, have never 'added a token'  so don't understand your difficulty. Typing 'b' [Ctrl]+J  creates the Begin - End; already but typing 'be' {Ctrl]+J creates Begin - End Else Begin - End; ---------------------------------------------------------------------- 741 · 2024-02-11 14:32 The thing is, when I do not want the else statement, then I need to remove it. So it would be faster to have a distinct shortcut for when I want only begin    | end; - which is the more common situation in my own experience. ---------------------------------------------------------------------- 741 · 2024-02-11 14:43 I've added an issue as suggested https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40764