Emmet for Sublime Text
Official Emmet plugin (previously called Zen Coding) for Sublime Text.
How to install
With Package Control:
- Run “Package Control: Install Package” command, find and install
- Restart ST editor (if required)
- Clone or download git repo into your packages folder (in ST, find Browse Packages... menu item to open this folder)
- Restart ST editor (if required)
WARNING: When plugin is installed, it will automatically download required PyV8 binary so you have to wait a bit (see Loading PyV8 binary message on status bar). If you experience issues with automatic PyV8 loader, try to install it manually.
- Expand Abbreviation – Tab or Ctrl+E
- Interactive “Expand Abbreviation” — Ctrl+Alt+Enter
- Match Tag Pair Outward – ⌃D (Mac) / Ctrl+, (PC)
- Match Tag Pair Inward – ⌃J / Shift+Ctrl+0
- Go to Matching Pair – ⇧⌃T / Ctrl+Alt+J
- Wrap With Abbreviation — ⌃W / Shift+Ctrl+G
- Go to Edit Point — Ctrl+Alt+→ or Ctrl+Alt+←
- Select Item – ⇧⌘. or ⇧⌘, / Shift+Ctrl+. or Shift+Ctrl+,
- Toggle Comment — ⇧⌥/ / Shift+Ctrl+/
- Split/Join Tag — ⇧⌘' / Shift+Ctrl+`
- Remove Tag – ⌘' / Shift+Ctrl+;
- Update Image Size — ⇧⌃I / Ctrl+U
- Evaluate Math Expression — ⇧⌘Y / Shift+Ctrl+Y
- Reflect CSS Value – ⇧⌘R / Shift+Ctrl+R
- Encode/Decode Image to data:URL – ⇧⌃D / Ctrl+'
- Rename Tag – ⇧⌘K / Shift+Ctrl+'
Increment/Decrement Number actions:
- Increment by 1: Ctrl+↑
- Decrement by 1: Ctrl+↓
- Increment by 0.1: Alt+↑
- Decrement by 0.1: Alt+↓
- Increment by 10: ⌥⌘↑ / Shift+Alt+↑
- Decrement by 10: ⌥⌘↓ / Shift+Alt+↓
You can easily extend Emmet with new actions and filters or customize existing ones. In
extensions_path setting and Emmet will load all
.json files in specified folder at startup.
The default value of
~/emmet, which points to emmet folder inside your OS user’s home folder.
Also, you can create sections named as extension files (e.g.
syntaxProfiles) inside user’s
Emmet.sublime-settings file and write your customizations there. See original settings file for examples.
Overriding keyboard shortcuts
Sublime Text is a great text editor with lots of features and actions. Most of these actions are bound to keyboard shortcuts so it’s nearly impossible to provide convenient plugin shortcuts for third-party plugins.
If you’re unhappy with default keymap, you can disable individual keyboard shortcuts with
disabled_keymap_actions preference of
Use a comma-separated list of action names which default keyboard shortcuts should be disabled. For example, if you want to release Ctrl+E (“Expand Abbreviation”) and Ctrl+U (“Update Image Size”) shortcuts, your must set the following value:
"disabled_keymap_actions": "expand_abbreviation, update_image_size"
You should refer
Default (Your-OS-Name).sublime-keymap file to get action ids (look for
To disable all default shortcuts, set value to
Not that if you disabled any action like so and you’re create your own keyboard shortcut, you should not use
emmet_action_enabled.ACTION_NAME context since this is the key that disables action.
Tab key handler
Emmet plugin allows you to expand abbreviations with Tab key, just like regular snippets. On the other hand, due to dynamic nature and extensive syntax, sometimes you may get unexpected results. This section describes how Tab handler works and how you can fine-tune it.
- You have to switch your document to one of the syntaxes listed above to expand abbreviations by Tab key.
- With Ctrl-E shortcut, you can expand abbreviations everywhere, its scope is not limited.
- When you expand abbreviation inside strings of programming languages, the output is generated with special output profile named
linethat generates output as a single line.
To fine-tune Tab key handler, you can use the following settings in user’s
disable_tab_abbreviations_for_scopes— a comma-separated list of syntax scopes where Tab key handler should be disabled. For example, if you want disable handler inside strings of programming languages and HAML syntax, your setting will look like this:
"disable_tab_abbreviations_for_scopes": "text.haml, string"
disabled_single_snippet_for_scopes— a comma-separated list of syntax scopes where Tab handler should be disabled when expanding a single abbreviation. Currently, ST doesn’t provide API for getting list of native snippets. So, for example, if you try to expand a
phpabbreviation, it will be passed to Emmet which outputs
<php></php>instead of PHP block as defined in native ST snippets. As a workaround, if you’re trying to expand a single abbreviation inside scope defined in
disabled_single_snippet_for_scopessetting Emmet will look for its name inside its own snippets catalog first, inside
known_html_tagssetting second and if it’s not found, it allows ST to handle it and expand native abbreviation, if matched.
known_html_tags— a space-separated list of all known HTML tags used for lookup as described above.
If you’re unhappy with Emmet tab handler behavior, you can disable it: just add
"disable_tab_abbreviations": true into user’s