Auto-closing paired symbols
When typing new templates, it would be very useful if certain opening/closing constructs were autocompleted. This applies to:
- the closing parenthesis after the argument list:
foo() - the template delimiters:
<<>>,<%%>,"" - placeholders
<>(also for customdelimiters?) - ifs:
<if()><endif> - anonymous templates:
<foo:{}> - ...?
Current status:
- [x] the closing parenthesis after the argument list: foo( )
- [x] the template delimiters: << >>, <% %>, " "
- [x] placeholders < >
- [x] (also for custom delimiters?)
- [ ] ifs:
<if( )><endif> - [x] quotes in attributes:
<foo format=" "> - [x] anonymous templates:
<foo:{ }>
Keep up the great work, @bjansen !
@bjansen
~~I just realized that format="" is not really special, the quotes are just template syntax. If "" and anonymous templates already work, then shouldn't this be covered too?~~
Remembering what I originally had in mind when I wrote the issue, it's about offering the option names format, wrap, separator, etc. as an autocomplete dropdown. The same case can be made for functions like strip, reverse, trim, ….
Re. <endif>, do you have an idea at what point of typing <if(...)> the <endif> should be inserted? Because I'm not sure what's most intuitive. After <if may be a little to early, in case they want to type <iframe> or whatever. Maybe after the parenthesis?
Remembering what I originally had in mind when I wrote the issue, it's about offering the option names format, wrap, separator, etc. as an autocomplete dropdown. The same case can be made for functions like strip, reverse, trim, ….
OK, so this is actual code completion (the other items were more "auto closing" than code completion per se).
do you have an idea at what point of typing <if(...)> the
should be inserted?
To be consistent with XML/HTML files, I suppose <endif> should be inserted when you type the closing >, but at the moment it's automatically inserted.
I've created #33 to separate the autoclosing of symbol pairs and actual autocompletion for identifiers and keywords.
For <endif> I think it makes sense to be consistent with HTML. Maybe it doesn't need to be autocompleted at all, I imagine it could be annoying when encasing existing template text within an if/endif. Adding <endif> when typing the closing > could be a nice way to make it opt-in.
If we make it opt-in, I think there's a good chance that users won't even know that the option exists, and thus it will never be used.
when encasing existing template text within an if/endif.
This is probably an opportunity to implement "Surround With..." :)
I agree, Surround With is a good idea. A similar feature is Live Templates, which could make the endif problem obsolete. Here's how it looks in a shell script:

You can already define your own live templates, but sure it would be better to ship them in the plugin directly.
Here's a preview of what I did so far. Most of what's listed in your request should work, except for <endif>s. I haven't figured out how to deal with that yet. Maybe "surround with" is enough?
Thanks, I tested the snapshot and found the following:
foo() ::= "did not insert the closing"delimiters "ditomyDict ::= [ "dito<foo:{did not insert}- when manually typing closing parentheses, it correctly replaces the automatically inserted one. This does not work for delimiters, however. I.e., if I press < and then >, it produces
<>>, while I would have expected<>.
Weird, it all works fine on my machine and in unit tests. How did you install the plugin?
I used "Install plugin from disk" and selected your zip file.
But I found the problem. I was testing at the top of an existing stg file. The templates had } and " scattered across. When testing at the bottom or in a blank file, it works indeed. My last point always happens though.