elky
elky

Reputation: 188

Sublime Text 2 - HTML autocomplete

In ST2 when you type div.foo and then press tab it goes to <div class="foo"></div>

Is there any setting to do autocompletion like that?

<div class="foo">
    // 4spaces here.
</div>

Thank you.

UPDATED

Didn't find a special setting but found where to change snippet if someone intested. In Sublime Text 2/Packages/HTML/html_completions.py just change

snippet = "<{0} class=\"{1}\">$1$0".format(tag, arg)

to

snippet = "<{0} class=\"{1}\">\n\t$1\n$0".format(tag, arg)

Solved.

Upvotes: 4

Views: 6168

Answers (2)

user2553340
user2553340

Reputation:

Make sure your page is on HTML. You can do this with CTRL+SHIFT+P. Then type 'set html'.

Then you can type div.class_name followed by TAB.

Upvotes: 0

EffectiX
EffectiX

Reputation: 316

You must be using emmet.... stock sublime text 2 does not auto complete class attribute from typing element.class that is emmet's doing. I use it... I love that emmet magic.

Similarly you could type element>element to make the second one nest on the first one. or element#id to add an id instead of a class...

Here is an entire cheat sheet for emmet for more completions using emmet plugin on ST2.

Upvotes: 1

Related Questions