delphilive-templates

Delphi live template to surround selection with parentheses


I'm trying to make a Delphi live template (in D2010) to surround a selection with (). My current attempt looks like:

<code language="Delphi" delimiter="|"><![CDATA[(|selected|)]]>

and it almost works but puts in extra whitespace. If I have a code line like:

if blah = 5 then

and I selected just the blah = 5 part and invoked my template I'd like it to come out like:

if (blah = 5) then

but it ends up being

if    (  blah = 5) then

Any suggestions?

Edit: Here's the entire template:

<?xml version="1.0" encoding="utf-8" ?>
<codetemplate   xmlns="http://schemas.borland.com/Delphi/2005/codetemplates"
                version="1.0.0">
    <template name="(" surround="true" invoke="none">
        <description>
          Surround selection by parentheses
        </description>
        <author>
          Mark Ford
        </author>
        <code language="Delphi" delimiter="|"><![CDATA[(|selected|)]]>
        </code>
    </template>
</codetemplate>

Solution

  • This appears to be a bug in the templates. It has been submitted as QC #21276.

    https://web.archive.org/web/20171221035806/http://qc.embarcadero.com/wc/qcmain.aspx?d=21276