SublimeText XML completions file

1

I apparently can't get autocompletion to work in my XML files. Here is my xml.sublime-completions file, which I added to the User folder:

{
  "scope": "text.xml",
  "completions":
  [
    {
      "trigger": "t",
      "contents": "<Text id="$1"><![CDATA[$0]]></Text>"
    }
  ]
}

Now typing t-<tab> in XML file only results in <t></t>:

<?xml version="1.0" encoding="UTF-8"?>
<t></t>

How to I even start debugging this?

Alexei Danchenkov

Posted 2015-04-23T07:19:06.740

Reputation: 353

Answers

1

It turned out a little more difficult than I anticipated.

  1. I had Emmet package installed. Emmet has own autocompletion support, but I did not manage to make it spit out the <![CDATA[...]]> sequence that I needed.

  2. So I disabled Emmet's autocompletion for xml scope by inserting the following in Emmet.sublime-settings:

    { "disable_tab_abbreviations_for_scopes": "text.xml" }

  3. Sublime snippets are themselves using <![CDATA[...]]> syntax for the replacement strings. Doh. <![CDATA[...]] tags can't be nested. It does not allow multiple CDATA inside 'content' tags either.

  4. Now the desired autocompletion works well in good old xml.sublime-completions:

    { "scope": "text.xml", "completions": [ { "trigger": "t", "contents": "<Text id="$1"><![CDATA[$0]]>/Text>" } ] }

Alexei Danchenkov

Posted 2015-04-23T07:19:06.740

Reputation: 353