Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortcut for adding id="" and class="" to HTML tags in Sublime Text 2

How do you set up Sublime Text 2 so that typing a . (period) produces class=" " and # (hash) produces id=" " when typing an opening HTML tag?

like image 719
Paul_S Avatar asked Feb 10 '15 21:02

Paul_S


People also ask

What is the shortcut key for Sublime Text?

The shortcut key for this purpose is Ctrl+Shift+P for Windows and Cmd+Shift+P for Mac.

Does Sublime Text have CSS?

Sublime Text contains a custom HTML and CSS engine, named minihtml, for displaying stylized content in editor panes. HTML content can be displayed in both popup windows and phantoms.


2 Answers

Type foo.bar, press Tab, and you'll get

<foo class="bar"></foo>

There's also foo#bar (for id instead of class). Both are implemented in Packages/HTML/html_completions.py

like image 109
Ir Calif Avatar answered Nov 16 '22 00:11

Ir Calif


I found the answer. Go to: Preferences -> Setting -> User.

add the following text between the curly braces, then save the file:

"auto_id_class": true,

this allows you to add id=" " and class=" " into HTML tags quickly, just by typing a # or .

If you use sublime text it's a nice feature.

like image 36
Paul_S Avatar answered Nov 15 '22 23:11

Paul_S