Home Download Buy Blog Forum Support

HTML snippets

HTML snippets

Postby qqq on Thu Mar 10, 2011 11:33 am

I read that they have to be implemented yet in ST2.

What makeshift solutions are available now for those who want to use HTML? Can these regex snippets be copied from 1.4? Or downloaded from anywhere?
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby qqq on Thu Mar 10, 2011 12:18 pm

I may be confusing something. Thought that's how they worked in 1.4 (not a separate snippet for each tag but all packed in HTML.tmLanguage file). Anyway no matter how you call them I would like to be able to use them :)
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby qqq on Fri Mar 11, 2011 7:56 am

Scope is surely the problem here.

I can easily enter tags in .html file but not in .php. I edited HTML.tmLanguage file adding:

Code: Select all
   <key>fileTypes</key>
   <array>
    (...)
      <string>php</string>
   </array>


but to no avail. Maybe I should edit HTML.sublime-completions as well? My only aim is to get it to work in .php files.
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby qqq on Fri Mar 11, 2011 9:35 am

I would be glad to have the option available wherever I happen to be in .php file.

As for HTML.sublime-completions its entire contents are:

Code: Select all
{
   "scope": "text.html - source - meta.tag, punctuation.definition.tag.begin",

   "completions":
   [
      { "trigger": "a", "contents": "<a href=\"$1\">$2</a>" },
      { "trigger": "abbr", "contents": "<abbr>$1</abbr>" },
      (...)
      { "trigger": "PARAM", "contents": "<PARAM>" }
   ]
}
I've tried several modifications but nothing came of it.
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby jps on Fri Mar 11, 2011 9:43 am

There should be no difference between PHP files and HTML files. Try opening an empty php file, and:

1) Check that the tab_completion setting is on, via running "view.settings().get('tab_completion')" in the console
2) Check the scope name, via Ctrl+Alt+P (Windows/Linux). It should be "text.html.basic".

Once you've checked both the above, then you should be able to complete HTML tags.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: HTML snippets

Postby qqq on Fri Mar 11, 2011 10:20 am

I changed tab_complitions to true, it works but still not the way I would like it to.

HTML tag completions work only outside <?php ?> block. I use a lot of heredoc which is always inside <?php ?> block.

When I'm inside php block php completions ovveride that of html. Typing "td" and hitting TAB results for example in: "cairo_matrix_transform_distance(matrix, dx, dy)", typing "span" and hitting TAB in "gupnp_service_proxy_add_notify(proxy, value, type, callback)". It is amazing how any tag I can think of triggers some mysterious php function :)
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby jps on Fri Mar 11, 2011 10:26 am

If you change the scope in the completions file to:

Code: Select all
"scope": "text.html - source - meta.tag, punctuation.definition.tag.begin, source.php",


Then you should be good to go.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: HTML snippets

Postby qqq on Fri Mar 11, 2011 10:43 am

Thanks, that helped.

I've one more question though. If I type say "table" and it completes after TAB and then inside of
Code: Select all
<table></table>

I type "tr" and press TAB again no completion is made only caret goes beyond table tag. Is this default behaviour?
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: HTML snippets

Postby jps on Fri Mar 11, 2011 11:15 am

It is, because you're still within the snippet fields. There are two options:

* Press escape, to cancel the snippet fields
* OR use Ctrl+Space, rather than tab, to insert the tr snippet
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: HTML snippets

Postby qqq on Fri Mar 11, 2011 1:18 pm

Ok.

I'm not exaclty happy with the fact that input->TAB gives simply:

Code: Select all
<input>


instead of:

Code: Select all
<input type="text" name="test" value="value" />


I can easily correct this in HTML.sublime-completions.

The question is what would be the best action if I want to protect my changes in this file from being overwritten? Should I copy it to the "User" folder (this works only if I add a new completion, if completion with the same trigger exists in the original file though it has higher priority)? Copying the whole "HTML" folder to "User" is basically doing the same thing so I don't expect it to work either.
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Next

Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 12 guests