emmet's support for emacs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jesús af67d1767c
update version
6 months ago
conf minor fix 6 months ago
src update version 6 months ago
tools fix non-security Environment 6 months ago
.gitignore generate dist to Makefile 6 months ago
.gitlab-ci.yml add .gitlab-ci 6 months ago
AUTHORS update list AUTHORS 6 months ago
LICENSE fix license 6 months ago
Makefile update version 6 months ago
README.md cleanup 6 months ago


This is a fork of zencoding-mode to support Emmet’s feature set.

Abbreviation Examples

Emmet Actions

Supported Emacs

emmet-mode is supported by GNU Emacs versions from 23 onward.


1. Manual Installation

Just make sure emmet-mode.el is in your load-path.

2. Settings to use.

If you manually installed emmet-mode to ~/emacs.d/emmet-mode/, add the following lines to your init.el or .emacs:

(add-to-list 'load-path "~/emacs.d/emmet-mode")
(require 'emmet-mode)

If you installed from marmalade/MELPA then these you shouldn’t need to do this.

Enable it by running M-x emmet-mode.

3. Optional settings

You probably want to add it to auto-load on your sgml modes:

(add-hook 'sgml-mode-hook 'emmet-mode) ;; Auto-start on any markup modes
(add-hook 'css-mode-hook  'emmet-mode) ;; enable Emmet's css abbreviation.

By default, inserted markup will be indented with indent-region, according to the buffer’s mode. To disable this, do:

(add-hook 'emmet-mode-hook (lambda () (setq emmet-indent-after-insert nil)))

If you disable indent-region, you can set the default indent level thusly:

(add-hook 'emmet-mode-hook (lambda () (setq emmet-indentation 2))) ;; indent 2 spaces.

If you want the cursor to be positioned between first empty quotes after expanding:

(setq emmet-move-cursor-between-quotes t) ;; default nil

Or if you don’t want to move cursor after expanding:

(setq emmet-move-cursor-after-expanding nil) ;; default t

If you want to use emmet with react-js’s JSX, you probably want emmet to expand ‘className=“…”’ instead of ‘class=“…”’:

(setq emmet-expand-jsx-className? t) ;; default nil

If you want to customize Self-closing tags style:

(setq emmet-self-closing-tag-style " /") ;; default "/"

;; only " /", "/" and "" are valid.
;; eg. <meta />, <meta/>, <meta>


Place point in a emmet snippet and press C-j to expand it (or alternatively, alias your preferred keystroke to M-x emmet-expand-line) and you’ll transform your snippet into the appropriate tag structure.

HTML abbreviations

Basic tags

a                        <a href=""></a>
a.x                      <a class="x" href=""></a>
a#q.x                    <a id="q" class="x" href=""></a>
a#q.x.y.z                <a id="q" class="x y z" href=""></a>
#q                       <div id="q">
.x                       <div class="x">
#q.x                     <div id="q" class="x">
#q.x.y.z                 <div id="q" class="x y z">

Empty tags

a/                       <a href=""/>
a/.x                     <a class="x" href=""/>
a/#q.x                   <a id="q" class="x" href=""/>
a/#q.x.y.z               <a id="q" class="x y z" href=""/>

Self-closing tags

input[type=text]         <input type="text" name="" value=""/>
img                      <img src="" alt=""/>
img>metadata/*2          <img src="" alt="">


a+b                      <a href=""></a>
a+b+c                    <a href=""></a>
a.x+b                    <a class="x" href=""></a>
a#q.x+b                  <a id="q" class="x" href=""></a>
a#q.x.y.z+b              <a id="q" class="x y z" href=""></a>
a#q.x.y.z+b#p.l.m.n      <a id="q" class="x y z" href=""></a>
                         <b id="p" class="l m n"></b>

Tag expansion

table+                   <table>
dl+                      <dl>
ul+                      <ul>
ul++ol+                  <ul>
ul#q.x.y[m=l]            <ul id="q" class="x y" m="l">

Parent > child

a>b                      <a href=""><b></b></a>
a>b>c                    <a href=""><b><c></c></b></a>
a.x>b                    <a class="x" href=""><b></b></a>
a#q.x>b                  <a id="q" class="x" href=""><b></b></a>
a#q.x.y.z>b              <a id="q" class="x y z" href=""><b></b></a>
a#q.x.y.z>b#p.l.m.n      <a id="q" class="x y z" href=""><b id="p" class="l m n"></b></a>
#q>.x                    <div id="q">
                             <div class="x">
a>b+c                    <a href="">
a>b+c>d                  <a href="">


a>b^c                    <a href=""><b></b></a><c></c>
a>b>c^d                  <a href="">
a>b>c^^d                 <a href=""><b><c></c></b></a>


a*1                      <a href=""></a>
a*2                      <a href=""></a>
                         <a href=""></a>
a/*2                     <a href=""/>
                         <a href=""/>
a*2+b*2                  <a href=""></a>
                         <a href=""></a>
a*2>b*2                  <a href="">
                         <a href="">
a>b*2                    <a href="">
a#q.x>b#q.x*2            <a id="q" class="x" href="">
                             <b id="q" class="x"></b>
                             <b id="q" class="x"></b>
a#q.x>b/#q.x*2           <a id="q" class="x" href="">
                             <b id="q" class="x"/>
                             <b id="q" class="x"/>

Item numbering

ul>li.item$*3            <ul>
                             <li class="item1"></li>
                             <li class="item2"></li>
                             <li class="item3"></li>
ul>li.item$$$*3          <ul>
                             <li class="item001"></li>
                             <li class="item002"></li>
                             <li class="item003"></li>
ul>li.item$@-*3          <ul>
                             <li class="item3"></li>
                             <li class="item2"></li>
                             <li class="item1"></li>
ul>li.item$@3*3          <ul>
                             <li class="item3"></li>
                             <li class="item4"></li>
                             <li class="item5"></li>
ul>li.item$@-3*3         <ul>
                             <li class="item5"></li>
                             <li class="item4"></li>
                             <li class="item3"></li>
a$b$@-/*5                <a1b5/>
a.$*2>b.$$@-*3           <a class=\"1\" href="">
                             <b class=\"03\"></b>
                             <b class=\"02\"></b>
                             <b class=\"01\"></b>
                         <a class=\"2\" href="">
                             <b class=\"03\"></b>
                             <b class=\"02\"></b>
                             <b class=\"01\"></b>
                             <a id=\"id01\" href=""></a>
                             <a id=\"id02\" href=""></a>
                             <b class=\"c4\"></b>
                             <c id=\"d1\"></c>
                             <a id=\"id01\" href=""></a>
                             <a id=\"id02\" href=""></a>
                             <b class=\"c3\"></b>
                             <c id=\"d2\"></c>
ul>li.c${price: 10\\$}*3 <ul>
                             <li class=\"c1\">price: 10$</li>
                             <li class=\"c2\">price: 10$</li>
                             <li class=\"c3\">price: 10$</li>


b[x]                     <b x=""></b>
b[x.]                    <b x></b>
b[x=]                    <b x=""></b>
b[x=""]                  <b x=""></b>
b[x=y]                   <b x="y"></b>
b[x="y"]                 <b x="y"></b>
b[x="()"]                <b x="()"></b>
b[x m]                   <b x="" m=""></b>
b[x. m]                  <b x m=""></b>
b[x m.]                  <b x="" m></b>
b[x. m.]                 <b x m></b>
b[x= m=""]               <b x="" m=""></b>
b[x=y m=l]               <b x="y" m="l"></b>
b/[x=y m=l]              <b x="y" m="l"/>
b#foo[x=y m=l]           <b id="foo" x="y" m="l"></b>
b.foo[x=y m=l]           <b class="foo" x="y" m="l"></b>
b#foo.bar.mu[x=y m=l]    <b id="foo" class="bar mu" x="y" m="l"></b>
b/#foo.bar.mu[x=y m=l]   <b id="foo" class="bar mu" x="y" m="l"/>
b[x=y]+b                 <b x="y"></b>
b[x=y]+b[x=y]            <b x="y"></b>
                         <b x="y"></b>
b[x=y]>b                 <b x="y"><b></b></b>
b[x=y]>b[x=y]            <b x="y"><b x="y"></b></b>
b[x=y]>b[x=y]+c[x=y]     <b x="y">
                             <b x="y"></b>
                             <c x="y"></c>


(a)                      <a href=""></a>
(a)+(b)                  <a href=""></a>
a>(b)                    <a href=""><b></b></a>
(a>b)>c                  <a href=""><b></b></a>
(a>b)+c                  <a href=""><b></b></a>
z+(a>b)+c+k              <z></z>
                         <a href=""><b></b></a>
(x)*2                    <x></x>
((x)*2)                  <x></x>
((x))*2                  <x></x>
(x>b)*2                  <x><b></b></x>
(x+b)*2                  <x></x>


a{Click me}              <a href="">Click me</a>
a>{Click me}*2           <a href="">
                             Click me
                             Click me
x{click}+b{here}         <x>click</x>
span>{click}+b{here}     <span>
p>{Click}+span{here}+{ to continue}
                              to continue
p{Click}+span{here}+{ to continue}
                          to continue
p{\{Escape brackets!\} and \\}
                         <p>{Escape brackets} and \</p>

Lorem-Ipsum generator

lorem                    Diam, vulputate ut pharetra sit amet, aliquam id! Egestas sed tempus, urna et pharetra pharetra, massa massa ultricies mi, quis hendrerit dolor magna eget est lorem ipsum dolor sit amet!
lorem5                   Hendrerit gravida rutrum quisque non?
ipsum3                   Viverra ipsum nunc.
p*3>lorem3               <p>Pellentesque elit eget?</p>
                         <p>Sed odio morbi?</p>
                         <p>Eget arcu dictum!</p>
ul.list>ipsum3*3         <ul class=\"list\">
                             Nam libero justo.
                             Pellentesque habitant morbi?
                             Enim blandit volutpat.
ul.list>ipsum3.itm*3     <ul class=\"list\">
                             <div class=\"itm\">Urna condimentum mattis.</div> <!-- emmet-mode doesn't support implicit tag name resolver -->
                             <div class=\"itm\">Sed turpis tincidunt.</div>
                             <div class=\"itm\">Faucibus turpis in?</div>
                         <ul class=\"list\">
                             <li class=\"itm\">Est pellentesque elit.</li>
                             <li class=\"itm\">In nulla posuere.</li>
                             <li class=\"itm\">Felis eget nunc.</li>

Filter: HTML with comments

a.b|c                    <!-- .b -->
                         <a class="b" href=""></a>
                         <!-- /.b -->
#a>.b|c                  <!-- #a -->
                         <div id="a">
                             <!-- .b -->
                             <div class="b">
                             <!-- /.b -->
                         <!-- /#a -->

Filter: HAML

a|haml                   %a
a#q.x.y.z|haml           %a#q.x.y.z
a#q.x[x=y m=l]|haml      %a#q.x{:x => "y", :m => "l"}
div|haml                 %div
div.footer|haml          .footer
.footer|haml             .footer
p>{txt}+a[href=#]+br|haml  %p
                             %a{:href => "#"}

Filter: Hiccup

a|hic                    [:a]
a#q.x.y.z|hic            [:a#q.x.y.z]
a#q.x[x=y m=l]|hic       [:a#q.x {:x "y", :m "l"}]
.footer|hic              [:div.footer]
p>a[href=#]+br|hic       [:p
                             [:a {:href "#"}]
#q>(a*2>b{x})+p>b|hic    [:div#q
                             [:a [:b "x"]]
                             [:a [:b "x"]]

Filter: escape

script[src=&quot;]|e     &lt;script src="&amp;quot;"&gt;


html:5                   <!doctype html>
                         <html lang="en">
                             <meta charset="UTF-8"/>

html:xt                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                         <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
                             <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>

meta:vp                  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
  • See HTML section of cheat-sheet to find more aliases.

CSS abbreviations

Basic Usage

p1-2!+m10e+bd1#2s        padding: 1px 2px !important;
                         margin: 10em;
                         border: 1px #222 solid;


m                        margin: ;
bg+                      background: #fff url() 0 0 no-repeat;
c                        color: #000;
  • See CSS section of cheat-sheet to find more keywords.


separate each value by ‘-’ or ‘ ‘;

m1-2-3-4                 margin: 1px 2px 3px 4px;
m1 2 3 4                 margin: 1px 2px 3px 4px;
m1--2                    margin: 1px -2px;
m1 -2                    margin: 1px -2px;

bg+#c /back.png 10 20 repeat-x
                         background: #cccccc url(/back.png) 10px 20px repeat-x;

Multiple property definition

concatenate each property by ‘+’;

m10+p0                   margin: 10px;
                         padding: 0px;

bg++c#0                  background: #fff url() 0 0 no-repeat;
                         color: #000;

                         margin: 0px;
                         padding: 10px;
                         color: #fff;
                         font-weight: bold;
                         width: 100px;
                         height: 20px;
                         background: #f00;

Value units

m10                      margin: 10px;
m1.5                     margin: 1.5em;
m1.5ex                   margin: 1.5ex;
m1.5x                    margin: 1.5ex;
m10foo                   margin: 10foo;
m10ex20em                margin: 10ex 20em;
m10x20e                  margin: 10ex 20em;
m10x-5                   margin: 10ex -5px;
w100p                    width: 100%;
m10p30e5x                margin: 10% 30em 5ex;
  • Unit-aliases

    e                        em
    p                        %
    x                        ex
    r                        rem

Unitless property

lh2                      line-height: 2;
fw400                    font-weight: 400;

Color abbreviations

c#3                      color: #333;
bd5#0s                   border: 5px #000 solid; /* s: solid, t: dotted, n: none, h: hidden */
bd5#20rgb                border: 5px rgb(32,32,32);
bd5#20rgbt               border: 5px rgb(32,32,32) dotted;
  • Color expansion

    #1                       #111
    #e0                      #e0e0e0
    #fc0                     #fc0


c#3!+bdrs2!              color: #333 !important;
                         border-radius: 2px !important;


Go to Edit Point

Traverse between important code points in HTML.

  • <C-M-left> is “Previous Edit Point” (M-x emmet-prev-edit-point)
  • <C-M-right> is “Next Edit Point” (M-x emmet-next-edit-point)

For further information and demo see Emmet’s documentation.

Development Notes

When working on emmet-mode. It is generated from the files in the /src directory by make.

$ make clean && make

Require pandoc for generate README.txt

# pacman -S pandoc

then run:

$ make docs