Emacs encoding-mode写HTML和CSS

Github: https://github.com/rooney/zencoding


About Zencoding

Description here and here.

I’ll quote the blog:

zen-coding includes an entirely new angle to writing markup, and it facilitates the feature by letting you write HTML based on CSS selectors. It’s so simple it’s confusing at first. I think it’s best explained by doing a quick before and after. If you were to type:

div#name.one.two

and follow that with the zen-coding plugin keystroke (CMD+E in TextMate), the plugin will reformat the line as:

<div id="name" class="one two"></div>

See the EmacsWiki for more background on this mode.

Screenshots and videos

Installation

Just make sure zencoding-mode.el is in your load-path, if you extracted zencoding-mode to a directory:

(add-to-list "~/emacs.d/zencoding-mode")

And then just require as normal:

(require 'zencoding-mode)

Usage

Enable it by running M-x zencoding-mode. You probably want to add it to auto-load on your sgml modes:

(add-hook 'sgml-mode-hook 'zencoding-mode) ;; Auto-start on any markup modes

Good to go: place point in a zencoding snippet and press C-j to expand it (or alternatively, alias your preferred keystroke to M-x zencoding-expand-line) and you'll transform your snippet into the appropriate tag structure.

Examples

Basic tags

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

Empty tags

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

Self-closing tags

input type=text          <input type="text"/>
img                      <img/>
img>metadata/*2          <img>
                             <metadata/>
                             <metadata/>
                         </img>

Siblings

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

Tag expansion

table+                   <table>
                             <tr>
                                 <td>
                                 </td>
                             </tr>
                         </table>
dl+                      <dl>
                             <dt></dt>
                             <dd></dd>
                         </dl>
ul+                      <ul>
                             <li></li>
                         </ul>
ul++ol+                  <ul>
                             <li></li>
                         </ul>
                         <ol>
                             <li></li>
                         </ol>
ul#q.x.y m=l+            <ul id="q" class="x y" m="l">
                             <li></li>
                         </ul>

Parent > child

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

Multiplication

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

Properties

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

Parentheses

(a)                      <a></a>
(a)+(b)                  <a></a>
                         <b></b>
a>(b)                    <a><b></b></a>
(a>b)>c                  <a><b></b></a>
(a>b)+c                  <a><b></b></a>
                         <c></c>
z+(a>b)+c+k              <z></z>
                         <a><b></b></a>
                         <c></c>
                         <k></k>
(a)*2                    <a></a>
                         <a></a>
((a)*2)                  <a></a>
                         <a></a>
((a))*2                  <a></a>
                         <a></a>
(a>b)*2                  <a><b></b></a>
                         <a><b></b></a>
(a+b)*2                  <a></a>
                         <b></b>
                         <a></a>
                         <b></b>

Filter: HTML with comments

a.b|c                    <!-- .b -->
                         <a class="b"></a>
                         <!-- /.b -->
#a>.b|c                  <!-- #a -->
                         <div id="a">
                             <!-- .b -->
                             <div class="b">
                             </div>
                             <!-- /.b -->
                         </div>
                         <!-- /#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>a href=#+br|haml       %p
                             %a{:href => "#"}
                             %br

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 "#"}]
                             [:br]]
#q>(a*2>b)+p>b|hic       [:div#q
                             [:a [:b]]
                             [:a [:b]]
                             [:p
                                 [:b]]]

Filter: escape

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Emacs Verilog Mode是一种用于在Emacs编辑器中编辑Verilog HDL(Hardware Description Language)的模式。它提供了丰富的功能和快捷键,使Verilog代码的编和调试更加方便和高效。 Emacs Verilog Mode具有以下主要特点: 1. 语法高亮显示:Verilog代码的不同部分会使用不同的颜色进行区分,以便更容易地阅读和理解代码。 2. 自动缩进:在编代码时,程序会自动进行缩进,以便更清晰地展示代码的层次结构。 3. 代码折叠:Emacs Verilog Mode允许代码的折叠和展开,以隐藏或显示特定的代码块。这样可以更好地组织和查看大型的Verilog项目。 4. 代码模板:模板功能使得可以快速插入常用的Verilog代码片段,例如模块定义、寄存器定义等,提高代码的编速度和一致性。 5. 代码跳转:通过快捷键可以方便地在模块之间进行跳转,快速浏览和编辑代码。 6. 语法检查和自动补全Emacs Verilog Mode可以检查代码中的语法错误,并提供自动补全功能,减少拼错误和编程失误。 7. 特定的功能块标记:针对Verilog HDL特有的结构和语法,Emacs Verilog Mode提供了特定的功能块标记,如module、always、if-else语句等,以便更好地识别和编辑这些代码块。 总之,Emacs Verilog Mode是一个强大而实用的工具,它简化了Verilog代码的编辑过程,提高了工作效率和代码质量。无论是进行硬件设计还是进行FPGA编程,使用Emacs Verilog Mode都能够帮助开发人员更好地完成任务。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值