Skip to content

Zen Coding:写HTML/CSS之辅助利器

2011 六月 6
by 荒野无灯

其实很早以前就认识这个插件了,这个插件几乎有所有流行编辑器的支持。
如DW,notepad++,Aptana/Eclipse,TextMate,Komodo Edit/IDE,Sublime Text,EmEditor等。
不过Vim版的插件并非官方支持的。
详见: zen-coding – Set of plugins for HTML and CSS hi-speed coding
Vim版的插件最新版目前是:0.53

ZenCoding.vim – vim plugins for HTML and CSS hi-speed coding. : vim online

介绍这个的文章已经相当多了,我这里简单说一下,备忘。
1,展开缩写

1
 <C-Y>,

如:

1
html:xs

会被展开为:

1
2
3
4
5
6
7
8
9
10
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <title></title>
</head>
<body>
   
</body>
</html>
1
div>p#foo$*3>a

会被展开为:

1
2
3
4
5
6
7
8
9
10
11
 <div>
      <p id="foo1">
          <a href=""></a>
      </p>
      <p id="foo2">
          <a href=""></a>
      </p>
      <p id="foo3">
          <a href=""></a>
      </p>
  </div>

2.用标签包围

test1
test2
test3

1
<C-Y>,

会提示你输入Tag,如输入:

1
 ul>li*

就变成了:

1
2
3
4
5
 <ul>
      <li>test1</li>
      <li>test2</li>
      <li>test3</li>
  </ul>

3,向内balance 标签
在插入模式下,要向内选择标签,用

1
<C-Y>d
1
2
3
4
5
  <ul>
  *   <li class="list1"></li>
      <li class="list2"></li>
      <li class="list3"></li>
  </ul>

如果光标在*号的位置 ,d 会选择从<ul>到</ul>的区域
如果光标在第一个<li>那么它会选择<li class=”list1″><li>

4,向外balance 标签
同样是在插入模式下,要向外选择标签,用

1
<C-Y>D

与上面的不同的是,
如果光标在*号那里,则会选择ul 后面的字符到</ul>前面的字符的区域。

5,跳到下一个编辑点
在插入模式下,

1
<C-Y>n

6,跳到上一个编辑点
在插入模式下,

1
<C-Y>N

7,展开或者更新img 标签的width , height 属性

1
<C-Y>i

8,合并多行
选择多行,然后按J(即此操作是在选择模式下进行的)

9,移除标签

1
<C-Y>k

10,分割/合并标签

1
<C-Y>j

11,添加/去除注释

1
<C-Y>/

12, 从URL生成锚标签

1
<C-Y>a

13, 从URL获取引用文本

1
<C-Y>A

另外,像等这些leaderkey 都是可以配置的,欲知详情请:

1
:h zencoding

文档:
https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL

http://mattn.github.com/zencoding-vim/

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=4562

3 Responses Post a comment
  1. surmise permalink
    八月 28, 2011

    √ html +ccss
    × c , c++ , java, php , linux ……………..
    适用性太窄.

  2. 六月 7, 2011

    跟楼上一模一样的飘过~

  3. 六月 6, 2011

    zen Coding + notepad++ 的飘过,完美,哈哈

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS