SublimeText XML-файл дополнений

965
Alexei Danchenkov

Я очевидно не могу заставить автозаполнение работать в моих файлах XML. Вот мой xml.sublime-completionsфайл, который я добавил в папку User:

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

Теперь ввод t- <tab> в XML-файле приводит только к <t> </ t>:

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

Как мне даже начать отлаживать это?

1

1 ответ на вопрос

1
Alexei Danchenkov

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>" } ] }