forked from VimPlug/emmet-vim
Compare commits
476 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70fe3aa22c | ||
|
|
9b3643796a | ||
|
|
40107b67c4 | ||
|
|
77855c4fe1 | ||
|
|
f0ba3ef4a5 | ||
|
|
eed6b2db44 | ||
|
|
7a25848537 | ||
|
|
672af42b71 | ||
|
|
95455cc4c8 | ||
|
|
34ce1afda0 | ||
|
|
9c02c521f1 | ||
|
|
bd8296d27c | ||
|
|
df2b758819 | ||
|
|
6b8e9720cf | ||
|
|
e5baec0d46 | ||
|
|
551740c720 | ||
|
|
3d7138f3ae | ||
|
|
272bad5c53 | ||
|
|
6575f65eaf | ||
|
|
e4bbc7fcd4 | ||
|
|
cc7a2ecf38 | ||
|
|
68f6e1851a | ||
|
|
e7af8d0793 | ||
|
|
72e10f85fe | ||
|
|
b45b08f5e8 | ||
|
|
b731410946 | ||
|
|
f60a983ae9 | ||
|
|
5c3abc98a2 | ||
|
|
7ad7c1032e | ||
|
|
2393c3772a | ||
|
|
2ad5bddc8c | ||
|
|
267b428943 | ||
|
|
7f38e6f78e | ||
|
|
2e3769f5d8 | ||
|
|
b46410cf05 | ||
|
|
d5a3582b6a | ||
|
|
8209775129 | ||
|
|
14ba403bf2 | ||
|
|
5244c6ec5e | ||
|
|
490802965d | ||
|
|
689ff1efab | ||
|
|
855e1a73df | ||
|
|
255902037d | ||
|
|
61a261ef89 | ||
|
|
e1e79f3d25 | ||
|
|
c55e379172 | ||
|
|
8194ee6683 | ||
|
|
43a9e6f962 | ||
|
|
c1ce62261f | ||
|
|
57754d9506 | ||
|
|
264df14c43 | ||
|
|
8d10026f61 | ||
|
|
aedd9026f0 | ||
|
|
403058a97d | ||
|
|
79c60d1cf5 | ||
|
|
09b6efb86b | ||
|
|
af0e4f1166 | ||
|
|
ca4675c02f | ||
|
|
24e65cd412 | ||
|
|
bddc3f9ff5 | ||
|
|
05688356b3 | ||
|
|
16e3a95d7f | ||
|
|
65c8fe1d23 | ||
|
|
e5b1e29964 | ||
|
|
968afb8cbd | ||
|
|
758f96e171 | ||
|
|
b61feb2f76 | ||
|
|
1ddb427987 | ||
|
|
d19b2b4fcd | ||
|
|
5011ea1dc6 | ||
|
|
edbf970d03 | ||
|
|
3fc634d532 | ||
|
|
c85ae9df08 | ||
|
|
ba8571bad6 | ||
|
|
15c3f99c68 | ||
|
|
fc604fc4b0 | ||
|
|
dcccfc6881 | ||
|
|
c35a379b27 | ||
|
|
8551b28a74 | ||
|
|
4c56e1146e | ||
|
|
b696d02b68 | ||
|
|
915726a88d | ||
|
|
01b6732fd6 | ||
|
|
b75f89ab57 | ||
|
|
b62af86318 | ||
|
|
d5145397cb | ||
|
|
19f984b165 | ||
|
|
faaaed9840 | ||
|
|
d71acb2c22 | ||
|
|
f5c6ad10dc | ||
|
|
c4494a24f6 | ||
|
|
1a9b7d2805 | ||
|
|
19db2eebe5 | ||
|
|
f6f4749be9 | ||
|
|
07d9400fbb | ||
|
|
70e54ff88e | ||
|
|
73e599e294 | ||
|
|
0f57b90bf9 | ||
|
|
c53d5a2971 | ||
|
|
843e99c883 | ||
|
|
b8ba003728 | ||
|
|
10687b23ac | ||
|
|
9835978968 | ||
|
|
85b6ed4349 | ||
|
|
2139620edf | ||
|
|
7967655b9c | ||
|
|
4dfd07003e | ||
|
|
d3f4db7367 | ||
|
|
3d3ae065eb | ||
|
|
1efd8a094f | ||
|
|
11af392af3 | ||
|
|
2ff5526a0c | ||
|
|
7b0c846018 | ||
|
|
80fda7de36 | ||
|
|
4c33c082c8 | ||
|
|
ddf38f4e99 | ||
|
|
75d229b320 | ||
|
|
e80ce9a642 | ||
|
|
b846bc72b8 | ||
|
|
a7e6a7ae03 | ||
|
|
99585c507c | ||
|
|
ace1bc521a | ||
|
|
d484c131b9 | ||
|
|
04b34844f1 | ||
|
|
c3785c4a1a | ||
|
|
9760bc0959 | ||
|
|
7fe889d214 | ||
|
|
06dd83dad3 | ||
|
|
dd44d64d56 | ||
|
|
b689b7a6e5 | ||
|
|
c2cf315a05 | ||
|
|
15a655a415 | ||
|
|
a1731c718d | ||
|
|
0330ce39b4 | ||
|
|
e3f72a588a | ||
|
|
9295915002 | ||
|
|
87def4ce94 | ||
|
|
ae2d88eed8 | ||
|
|
6751400cce | ||
|
|
57e43e4833 | ||
|
|
14fb367409 | ||
|
|
c8ec156876 | ||
|
|
98f716c4d1 | ||
|
|
b18d8ce9ab | ||
|
|
24a0418274 | ||
|
|
1b42bbd78e | ||
|
|
8ec50c24f5 | ||
|
|
0d2026b1f1 | ||
|
|
0a4e2db3cc | ||
|
|
f4d804dbaf | ||
|
|
17724b9522 | ||
|
|
7b6341f88b | ||
|
|
316923ecbe | ||
|
|
b0732a00d0 | ||
|
|
08666e545d | ||
|
|
33b90dcaf1 | ||
|
|
af3a1acf40 | ||
|
|
c3ffd8727e | ||
|
|
cf8c5b35f7 | ||
|
|
aea4becc0e | ||
|
|
b13fc41a35 | ||
|
|
1b937875b4 | ||
|
|
72d344174f | ||
|
|
d40f63c724 | ||
|
|
918be7d824 | ||
|
|
13672245b3 | ||
|
|
9c042e6907 | ||
|
|
e1015e8470 | ||
|
|
4a0e7d1fb2 | ||
|
|
104a4b5ac0 | ||
|
|
13f4b677c9 | ||
|
|
ad19b79b65 | ||
|
|
f1bb86e57e | ||
|
|
7453ca403c | ||
|
|
540480bd6b | ||
|
|
0eddf94b6f | ||
|
|
bdf8c3ffe1 | ||
|
|
cb7cb86184 | ||
|
|
52fbf6d33e | ||
|
|
3e679f8a9a | ||
|
|
1883fecec0 | ||
|
|
8126a94272 | ||
|
|
f66501ccd1 | ||
|
|
c492fc64f0 | ||
|
|
01524e272f | ||
|
|
5efe248f0e | ||
|
|
3766ec94ea | ||
|
|
4d295a516b | ||
|
|
e6e89137e2 | ||
|
|
62c8a5c39e | ||
|
|
d4c971b7c4 | ||
|
|
61ca294004 | ||
|
|
d7e4896a28 | ||
|
|
6eff2a965f | ||
|
|
c9398065c8 | ||
|
|
a386d41384 | ||
|
|
65588192a4 | ||
|
|
732a8aa1d1 | ||
|
|
1f4dbe3917 | ||
|
|
513578327c | ||
|
|
0e104e30f5 | ||
|
|
1bb674d731 | ||
|
|
3dac32d31c | ||
|
|
475d1b0a6f | ||
|
|
aca236d40d | ||
|
|
304fb93d16 | ||
|
|
66b00b5e40 | ||
|
|
6f7d59c030 | ||
|
|
16a09f81c1 | ||
|
|
74331b5545 | ||
|
|
f7047e7520 | ||
|
|
afabf9d4a0 | ||
|
|
c1ea1e576b | ||
|
|
e7b6ce30f1 | ||
|
|
4b4aef917b | ||
|
|
e123792281 | ||
|
|
ba5c040894 | ||
|
|
e16879217d | ||
|
|
32aacd57ab | ||
|
|
b05a4e281f | ||
|
|
ec071d3b63 | ||
|
|
896520d48e | ||
|
|
6b65455e94 | ||
|
|
6521d273fb | ||
|
|
ac6d7fb269 | ||
|
|
0072354226 | ||
|
|
99b6e2d292 | ||
|
|
115f68df62 | ||
|
|
accc9934d2 | ||
|
|
7bed58f537 | ||
|
|
3ce2d835be | ||
|
|
47a4d1ffa3 | ||
|
|
8f8cd747b2 | ||
|
|
b0b2323d3a | ||
|
|
773f87b62b | ||
|
|
eaa447fb40 | ||
|
|
f8f9dcd72e | ||
|
|
450768be48 | ||
|
|
54924cb5d5 | ||
|
|
f34dd90f73 | ||
|
|
44619b2584 | ||
|
|
775dfb99e2 | ||
|
|
d9957b0baf | ||
|
|
c5db7c80d2 | ||
|
|
f844ab85b0 | ||
|
|
43f36d6069 | ||
|
|
8d6256e1f8 | ||
|
|
8f290b913e | ||
|
|
25ecc2ca99 | ||
|
|
95df77c224 | ||
|
|
e799b8ead5 | ||
|
|
d67f118b13 | ||
|
|
88d89910e2 | ||
|
|
6f584f3419 | ||
|
|
dcc75d8a19 | ||
|
|
7ccba3e1bb | ||
|
|
4bbbe1d3de | ||
|
|
2091f33c82 | ||
|
|
77e480c140 | ||
|
|
aa7d54e0f0 | ||
|
|
3ece783f74 | ||
|
|
3ba6851c1a | ||
|
|
9a941aad9b | ||
|
|
8b8aa71043 | ||
|
|
e4dc78bc9b | ||
|
|
cda02374cd | ||
|
|
96e256df37 | ||
|
|
1bbf5b06ad | ||
|
|
72ef007a84 | ||
|
|
d9b9733bd0 | ||
|
|
771343cf24 | ||
|
|
eefd49426f | ||
|
|
555aee4d3d | ||
|
|
0dcce23ef0 | ||
|
|
1e63393779 | ||
|
|
19bfc84054 | ||
|
|
fe99a324a9 | ||
|
|
010a744683 | ||
|
|
b960a0d6ab | ||
|
|
17dfb732a8 | ||
|
|
a722f513e1 | ||
|
|
295bceb85a | ||
|
|
d4287a23d4 | ||
|
|
fd46018e06 | ||
|
|
4cf35d61e0 | ||
|
|
6d455bfeae | ||
|
|
cb13e4a07d | ||
|
|
aeb24b1922 | ||
|
|
e72254f40a | ||
|
|
e3a9428c1d | ||
|
|
af324f7db0 | ||
|
|
e6299244b7 | ||
|
|
ca38aaa673 | ||
|
|
6d8d5a6ee2 | ||
|
|
8b98743ff0 | ||
|
|
97e438a40b | ||
|
|
6d0c90f7d0 | ||
|
|
5ed0a7e599 | ||
|
|
feb6b8ca14 | ||
|
|
16e048aaf4 | ||
|
|
51bcdaa181 | ||
|
|
2d9d13e4bd | ||
|
|
c623a72a39 | ||
|
|
7ac94b6e64 | ||
|
|
742e115a41 | ||
|
|
62ef855ef4 | ||
|
|
748e969191 | ||
|
|
e6bdb86c2f | ||
|
|
f77a31b174 | ||
|
|
a639eee9d8 | ||
|
|
0ec7f16fde | ||
|
|
be54da653a | ||
|
|
4ff2179ee3 | ||
|
|
d7b9436e67 | ||
|
|
de6198ab35 | ||
|
|
22ddd21796 | ||
|
|
5788d9eb52 | ||
|
|
85cc6b07a3 | ||
|
|
346e5cd99d | ||
|
|
e3ec54fb21 | ||
|
|
53871006c1 | ||
|
|
a75e00c0bf | ||
|
|
6bc305a910 | ||
|
|
b7f309f729 | ||
|
|
11b5ffa598 | ||
|
|
304e0e386b | ||
|
|
157bad472e | ||
|
|
afbcac04b4 | ||
|
|
f2cb7b112c | ||
|
|
93104ffff5 | ||
|
|
e649cd2ad8 | ||
|
|
b60a67d64e | ||
|
|
0d857c3959 | ||
|
|
a50d3cfcdb | ||
|
|
7aef89ccd4 | ||
|
|
0e3cce60ac | ||
|
|
3aa240f7b8 | ||
|
|
6b8149e726 | ||
|
|
9f6c077cb8 | ||
|
|
ff77763c0a | ||
|
|
282a3a9958 | ||
|
|
d78b041fd0 | ||
|
|
66d173288c | ||
|
|
0c28ad1791 | ||
|
|
5fb57a28d3 | ||
|
|
06130914c6 | ||
|
|
8c2a246bee | ||
|
|
76b476eb45 | ||
|
|
a2a8882f7a | ||
|
|
f78d448252 | ||
|
|
7f0e2a13d0 | ||
|
|
8c958179a3 | ||
|
|
bdf2d62559 | ||
|
|
2de194d06c | ||
|
|
c909e11879 | ||
|
|
deeca32153 | ||
|
|
805d715be0 | ||
|
|
6571c87336 | ||
|
|
ed3874f065 | ||
|
|
6c4a79e963 | ||
|
|
d9e7b4cf2a | ||
|
|
8d047d302b | ||
|
|
8df0a44996 | ||
|
|
b92c1a37a9 | ||
|
|
e212a6a696 | ||
|
|
a8ce3841d6 | ||
|
|
21b5d07790 | ||
|
|
7068617f92 | ||
|
|
d6c82b3f2d | ||
|
|
5e1002b3aa | ||
|
|
7e33ea1a7e | ||
|
|
1de3fbe918 | ||
|
|
d9976b5d56 | ||
|
|
6712c04459 | ||
|
|
c047dba32b | ||
|
|
9a4412e816 | ||
|
|
ad794a21f0 | ||
|
|
8eec4c219d | ||
|
|
9fab173af3 | ||
|
|
65a64a6e8b | ||
|
|
4ba6dde573 | ||
|
|
37166712b2 | ||
|
|
f7d32c0987 | ||
|
|
e77872ec0b | ||
|
|
c6e7a3038f | ||
|
|
ca1e9c9b9c | ||
|
|
a1cbb01c78 | ||
|
|
5c7a135bd4 | ||
|
|
031a88c4c6 | ||
|
|
7b26a71768 | ||
|
|
dbedf03e00 | ||
|
|
783c6a10f6 | ||
|
|
404609b08a | ||
|
|
7d5b6609d3 | ||
|
|
df3eb4ecba | ||
|
|
ac2d5dcd47 | ||
|
|
8376d08247 | ||
|
|
d74c2928a1 | ||
|
|
69970b1621 | ||
|
|
46fd337636 | ||
|
|
72503f954d | ||
|
|
10457913ea | ||
|
|
b9c63d08e1 | ||
|
|
af7aeca083 | ||
|
|
e22429aba9 | ||
|
|
4c34110628 | ||
|
|
0e21c19f6f | ||
|
|
33d049492b | ||
|
|
7587bf534f | ||
|
|
4a4885c7a8 | ||
|
|
3b18a7fc77 | ||
|
|
339be72156 | ||
|
|
605f3d8ce3 | ||
|
|
0d96516ed3 | ||
|
|
2e5268f285 | ||
|
|
b2dc5ba2d4 | ||
|
|
5f4ed21dde | ||
|
|
91d0385785 | ||
|
|
55b93c7aaa | ||
|
|
0aa0356d30 | ||
|
|
0f9662bc1b | ||
|
|
ada3c0e51a | ||
|
|
5a0b8d4e76 | ||
|
|
249cc98320 | ||
|
|
52d62129ab | ||
|
|
17e161ef32 | ||
|
|
92f604e1bd | ||
|
|
5d143b1974 | ||
|
|
99460233b4 | ||
|
|
4e26621542 | ||
|
|
b66dfbe365 | ||
|
|
3d9fbfd049 | ||
|
|
0baf7df3f3 | ||
|
|
55df3e1a06 | ||
|
|
729634a1b4 | ||
|
|
ed98e0faa5 | ||
|
|
cb0a48ea32 | ||
|
|
c540355f8e | ||
|
|
818044551a | ||
|
|
f928b2182c | ||
|
|
c51e890194 | ||
|
|
8118f59eae | ||
|
|
895147684e | ||
|
|
ccbf87b817 | ||
|
|
192fc49720 | ||
|
|
8a2c4f1628 | ||
|
|
208553fc27 | ||
|
|
40a44a60c8 | ||
|
|
a81f95f02f | ||
|
|
f91c1f4b64 | ||
|
|
60a8850e7c | ||
|
|
5fadd04e14 | ||
|
|
304586f056 | ||
|
|
f1e11a5fae | ||
|
|
671226c005 | ||
|
|
ab37be12b1 | ||
|
|
cc1845bbad | ||
|
|
571654c416 | ||
|
|
d314aac8e5 | ||
|
|
6f131081df | ||
|
|
39978b46da | ||
|
|
aa53f1a1b9 | ||
|
|
e7727ecd3a | ||
|
|
10529b0fd2 | ||
|
|
3fa5f954b5 | ||
|
|
7b53ee106b | ||
|
|
b70c4881d9 | ||
|
|
50cc0229f0 | ||
|
|
3c4e5deb1c | ||
|
|
8de8625b6f | ||
|
|
dfa521dabd | ||
|
|
71e739e770 | ||
|
|
d2a98bbc0a | ||
|
|
a84a668b3b | ||
|
|
cacb5b4715 | ||
|
|
e3397ed866 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/doc/tags
|
||||
4
.gitmodules
vendored
Normal file
4
.gitmodules
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
[submodule "docs"]
|
||||
path = docs
|
||||
url = git@github.com:mattn/zencoding-vim.git
|
||||
branch = gh-pages
|
||||
11
Makefile
Normal file
11
Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
all : zencoding-vim.zip
|
||||
|
||||
remove-zip:
|
||||
-rm doc/tags
|
||||
-rm zencoding-vim.zip
|
||||
|
||||
zencoding-vim.zip: remove-zip
|
||||
zip -r zencoding-vim.zip autoload plugin doc
|
||||
|
||||
release: zencoding-vim.zip
|
||||
vimup update-script zencoding.vim
|
||||
93
README.mkd
Normal file
93
README.mkd
Normal file
@@ -0,0 +1,93 @@
|
||||
# ZenCoding-vim
|
||||
|
||||
[zencoding-vim](http://mattn.github.com/zencoding-vim) is vim script support for expanding abbreviation like zen-coding(emmet).
|
||||
|
||||
## Installation
|
||||
|
||||
[Download zip file](http://www.vim.org/scripts/script.php?script_id=2981):
|
||||
|
||||
cd ~/.vim
|
||||
unzip zencoding-vim.zip
|
||||
|
||||
If you install pathogen.vim:
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
unzip /path/to/zencoding-vim.zip
|
||||
|
||||
If you get source from repository:
|
||||
|
||||
cd ~/.vim/bundle # or make directory
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
or:
|
||||
|
||||
git clone http://github.com/mattn/zencoding-vim.git
|
||||
cd zencoding-vim
|
||||
cp plugin/zencoding.vim ~/.vim/plugin/
|
||||
cp autoload/zencoding.vim ~/.vim/autoload/
|
||||
|
||||
|
||||
## Quick Tutorial
|
||||
|
||||
Open or create New File:
|
||||
|
||||
vim index.html
|
||||
|
||||
Type ("_" is the cursor position):
|
||||
|
||||
html:5_
|
||||
|
||||
Then type "<c-y>," (Ctrl + y + ','), you should see:
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
_
|
||||
</body>
|
||||
</html>
|
||||
|
||||
[More Tutorials](https://raw.github.com/mattn/zencoding-vim/master/TUTORIAL)
|
||||
|
||||
|
||||
## Project Authors
|
||||
|
||||
[Yasuhiro Matsumoto](http://mattn.kaoriya.net/)
|
||||
|
||||
## Links
|
||||
|
||||
### zen-coding official site:
|
||||
|
||||
> <http://code.google.com/p/zen-coding/>
|
||||
|
||||
### zencoding.vim:
|
||||
|
||||
> <http://mattn.github.com/zencoding-vim>
|
||||
|
||||
### development repository:
|
||||
|
||||
> <https://github.com/mattn/zencoding-vim>
|
||||
|
||||
### my blog posts about zencoding-vim:
|
||||
|
||||
> <http://mattn.kaoriya.net/software/vim/20100222103327.htm>
|
||||
|
||||
> <http://mattn.kaoriya.net/software/vim/20100306021632.htm>
|
||||
|
||||
### japanese blog posts about zencoding-vim:
|
||||
|
||||
> <http://d.hatena.ne.jp/idesaku/20100424/1272092255>
|
||||
|
||||
> <http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding>
|
||||
|
||||
> <http://d.hatena.ne.jp/sakurako_s/20110126/1295988873>
|
||||
|
||||
> <http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html>
|
||||
|
||||
### tutorial traslated in chinese:
|
||||
|
||||
> <http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html>
|
||||
|
||||
212
TUTORIAL
Normal file
212
TUTORIAL
Normal file
@@ -0,0 +1,212 @@
|
||||
Tutorial of zencoding.vim
|
||||
|
||||
mattn <mattn.jp@gmail.com>
|
||||
|
||||
1. Expand Abbreviation
|
||||
|
||||
Type abbreviation as 'div>p#foo$*3>a' and type '<c-y>,'.
|
||||
---------------------
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
2. Wrap with Abbreviation
|
||||
|
||||
Write as below.
|
||||
---------------------
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
---------------------
|
||||
Then do visual select(line wize) and type '<c-y>,'.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
---------------------
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
---------------------
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
3. Balance Tag Inward
|
||||
|
||||
type '<c-y>d' in insert mode.
|
||||
|
||||
4. Balance Tag Outward
|
||||
|
||||
type '<c-y>D' in insert mode.
|
||||
|
||||
5. Go to Next Edit Point
|
||||
|
||||
type '<c-y>n' in insert mode.
|
||||
|
||||
6. Go to Previous Edit Point
|
||||
|
||||
type '<c-y>N' in insert mode.
|
||||
|
||||
7. Update <img> Size
|
||||
|
||||
Move cursor to img tag.
|
||||
---------------------
|
||||
<img src="foo.png" />
|
||||
---------------------
|
||||
Type '<c-y>i' on img tag
|
||||
---------------------
|
||||
<img src="foo.png" width="32" height="48" />
|
||||
---------------------
|
||||
|
||||
8. Merge Lines
|
||||
|
||||
select the lines included '<li>'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
and type '<c-y>m'
|
||||
---------------------
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
---------------------
|
||||
|
||||
9. Remove Tag
|
||||
|
||||
Move cursor in block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>k' in insert mode.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>k' in there again.
|
||||
---------------------
|
||||
|
||||
---------------------
|
||||
|
||||
10. Split/Join Tag
|
||||
|
||||
Move cursor in block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>j' in insert mode.
|
||||
---------------------
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
|
||||
And type '<c-y>j' in there again.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
Move cursor to block
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-y>/' in insert mode.
|
||||
---------------------
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
---------------------
|
||||
Type '<c-y>/' in there again.
|
||||
---------------------
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
12. Make anchor from URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
http://www.google.com/
|
||||
---------------------
|
||||
Type '<c-y>a'
|
||||
---------------------
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
---------------------
|
||||
|
||||
13. Make quoted text from URL
|
||||
|
||||
Move cursor to URL
|
||||
---------------------
|
||||
http://github.com/
|
||||
---------------------
|
||||
Type '<c-y>A'
|
||||
---------------------
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
---------------------
|
||||
|
||||
14. Installing zencoding.vim for language you using.
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
15. Enable zencoding.vim for language you using.
|
||||
|
||||
You can customize the behavior of language you using.
|
||||
|
||||
---------------------
|
||||
# cat >> ~/.vimrc
|
||||
let g:user_zen_settings = {
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'c',
|
||||
\ },
|
||||
\ 'xml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\ 'haml' : {
|
||||
\ 'extends' : 'html',
|
||||
\ },
|
||||
\}
|
||||
---------------------
|
||||
1442
autoload/zencoding.vim
Normal file
1442
autoload/zencoding.vim
Normal file
File diff suppressed because it is too large
Load Diff
11
autoload/zencoding/lang.vim
Normal file
11
autoload/zencoding/lang.vim
Normal file
@@ -0,0 +1,11 @@
|
||||
let s:exists = {}
|
||||
function zencoding#lang#exists(type)
|
||||
if len(a:type) == 0
|
||||
return 0
|
||||
elseif has_key(s:exists, a:type)
|
||||
return s:exists[a:type]
|
||||
endif
|
||||
let s:exists[a:type] = len(globpath(&rtp, 'autoload/zencoding/lang/'.a:type.'.vim')) > 0
|
||||
return s:exists[a:type]
|
||||
endfunction
|
||||
|
||||
228
autoload/zencoding/lang/css.vim
Normal file
228
autoload/zencoding/lang/css.vim
Normal file
@@ -0,0 +1,228 @@
|
||||
function! zencoding#lang#css#findTokens(str)
|
||||
return substitute(a:str, '^.*[;{]\s*', '', '')
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
let prefix = 0
|
||||
let value = ''
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
|
||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
|
||||
" emmet
|
||||
let tokens = split(abbr, '+\ze[^)!]')
|
||||
for n in range(len(tokens))
|
||||
let token = tokens[n]
|
||||
let prop = matchlist(token, '^\(-\{0,1}[a-zA-Z]\+\|[a-zA-Z0-9]\++\{0,1}\|([a-zA-Z0-9]\++\{0,1})\)\(\%([0-9.-]\+[pe]\{0,1}-\{0,1}\|-auto\)*\)$')
|
||||
if len(prop)
|
||||
let token = substitute(prop[1], '^(\(.*\))', '\1', '')
|
||||
if token =~ '^-'
|
||||
let prefix = 1
|
||||
let token = token[1:]
|
||||
endif
|
||||
let value = ''
|
||||
for v in split(prop[2], '\d\zs-')
|
||||
if len(value) > 0
|
||||
let value .= ' '
|
||||
endif
|
||||
if token =~ '^[z]'
|
||||
" TODO
|
||||
let value .= substitute(v, '[^0-9.]*$', '', '')
|
||||
elseif v =~ 'p$'
|
||||
let value .= substitute(v, 'p$', '%', '')
|
||||
elseif v =~ 'e$'
|
||||
let value .= substitute(v, 'e$', 'em', '')
|
||||
elseif v =~ '\.'
|
||||
let value .= v . 'em'
|
||||
elseif v == 'auto'
|
||||
let value .= v
|
||||
else
|
||||
let value .= v . 'px'
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
let tag_name = token
|
||||
if tag_name =~ '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
else
|
||||
let important = 0
|
||||
endif
|
||||
" make default node
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': important }
|
||||
let current.name = tag_name
|
||||
|
||||
" aliases
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, tag_name)
|
||||
let snippet = snippets[tag_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
let current.snippet = substitute(current.snippet, ';', value . ';', '')
|
||||
if use_pipe_for_cursor && len(value) > 0 && stridx(value, '${cursor}') == -1
|
||||
let current.snippet = substitute(current.snippet, '${cursor}', '', 'g') . '${cursor}'
|
||||
endif
|
||||
if n < len(tokens) - 1
|
||||
let current.snippet .= "\n"
|
||||
endif
|
||||
endif
|
||||
|
||||
let current.pos = 0
|
||||
let lg = matchlist(token, '^\%(linear-gradient\|lg\)(\s*\(\w\+\)\s*,\s*\([^,]\+\)\s*,\s*\([^)]\+\)\s*)$')
|
||||
if len(lg)
|
||||
let current.name = ''
|
||||
let current.snippet = printf("background-image: -webkit-gradient(%s, 0 0, 0 100%, from(%s), to(%s));\n", lg[1], lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -webkit-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -moz-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: -o-linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = printf("background-image: linear-gradient(%s, %s);\n", lg[2], lg[3])
|
||||
call add(root.child, deepcopy(current))
|
||||
elseif prefix
|
||||
let snippet = current.snippet
|
||||
let current.snippet = '-webkit-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = '-moz-' . snippet . "\n"
|
||||
call add(root.child, deepcopy(current))
|
||||
let current.snippet = snippet
|
||||
call add(root.child, current)
|
||||
else
|
||||
call add(root.child, current)
|
||||
endif
|
||||
endfor
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let current = a:current
|
||||
let value = current.value[1:-2]
|
||||
if zencoding#useFilter(a:filters, 'fc')
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1: \2', 'g')
|
||||
else
|
||||
let value = substitute(value, '\([^:]\+\):\([^;]*;\)', '\1:\2', 'g')
|
||||
endif
|
||||
if current.important
|
||||
let value = substitute(value, ';', ' !important;', '')
|
||||
endif
|
||||
return value
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#parseTag(tag)
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#toggleComment()
|
||||
let line = getline('.')
|
||||
let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$'
|
||||
if line =~ '{\s*$'
|
||||
let block = zencoding#util#searchRegion('/\*', '\*/\zs')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
else
|
||||
let node = expand('<cword>')
|
||||
if len(node)
|
||||
exe "normal ciw\<c-r>='/* '.node.' */'\<cr>"
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if line =~ mx
|
||||
let space = substitute(matchstr(line, mx), mx, '\1', '')
|
||||
let line = substitute(matchstr(line, mx), mx, '\2', '')
|
||||
let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g')
|
||||
else
|
||||
let mx = '^\(\s*\)\(.*\)\s*$'
|
||||
let line = substitute(line, mx, '\1/* \2 */', '')
|
||||
endif
|
||||
call setline('.', line)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
if a:flag > 0
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
if a:flag > 0
|
||||
let content = zencoding#util#getContent(block)
|
||||
if content !~ '^{.*}$'
|
||||
let block = zencoding#util#searchRegion('{', '}')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
else
|
||||
let pos = searchpos('.*;', 'nW')
|
||||
if pos[0] != 0
|
||||
call setpos('.', [0, pos[0], pos[1], 0])
|
||||
let block = zencoding#util#searchRegion('^', ';')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#moveNextPrev(flag)
|
||||
let pos = search('""\|()\|\(:\s*\zs$\)', a:flag ? 'Wbp' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
else
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#splitJoinTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#css#removeTag()
|
||||
" nothing to do
|
||||
endfunction
|
||||
303
autoload/zencoding/lang/haml.vim
Normal file
303
autoload/zencoding/lang/haml.vim
Normal file
@@ -0,0 +1,303 @@
|
||||
function! zencoding#lang#haml#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
|
||||
let comment_indent = ''
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= '%' . current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let valtmp = substitute(val, '\${cursor}', '', '')
|
||||
if attr == 'id' && len(valtmp) > 0
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class' && len(valtmp) > 0
|
||||
let str .= '.' . substitute(val, ' ', '.', 'g')
|
||||
else
|
||||
if len(tmp) > 0 | let tmp .= ',' | endif
|
||||
let val = substitute(val, '\${cursor}', '', '')
|
||||
let tmp .= ' :' . attr . ' => "' . val . '"'
|
||||
endif
|
||||
endfor
|
||||
if len(tmp)
|
||||
let str .= '{' . tmp . ' }'
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1 && len(current.value) == 0
|
||||
let str .= "/"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let lines = split(text, "\n")
|
||||
if len(lines) == 1
|
||||
let str .= " " . text
|
||||
else
|
||||
for line in lines
|
||||
let str .= "\n" . indent . line . " |"
|
||||
endfor
|
||||
endif
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
let str .= "\n"
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#imageSize()
|
||||
let line = getline('.')
|
||||
let current = zencoding#lang#haml#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let haml = zencoding#toString(current, 'haml', 1)
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . haml, "\n", "", "g"))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
let mx = '%\([a-zA-Z][a-zA-Z0-9]*\)\s*\%({\(.*\)}\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9]\+\)\s*=>\s*\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#toggleComment()
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*-#'
|
||||
call setline('.', space . matchstr(line[len(space)+2:], '^\s*\zs.*'))
|
||||
elseif line =~ '^\s*%[a-z]'
|
||||
call setline('.', space . '-# ' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze%[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#moveNextPrev(flag)
|
||||
let pos = search('""', a:flag ? 'Wb' : 'W')
|
||||
if pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#splitJoinTag()
|
||||
let n = line('.')
|
||||
let sml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze%[a-z]'
|
||||
if len(matchstr(getline(n), '^\s*%[a-z]')) < sml
|
||||
break
|
||||
endif
|
||||
let line = getline(n)
|
||||
call setline(n, substitute(line, '^\s*%\w\+\%(\s*{[^}]*}\|\s\)\zs.*', '', ''))
|
||||
let sn = n
|
||||
let n += 1
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if len(matchstr(getline(n), '^\s*')) > ml
|
||||
while n <= line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*'))
|
||||
if l <= ml
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let tag = matchstr(getline(sn), '^\s*%\zs\(\w\+\)')
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
let settings = zencoding#getSettings()
|
||||
if stridx(','.settings.html.inline_elements.',', ','.tag.',') == -1
|
||||
call append(sn, spaces . ' ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
else
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#haml#removeTag()
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*%[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
endif
|
||||
endfunction
|
||||
673
autoload/zencoding/lang/html.vim
Normal file
673
autoload/zencoding/lang/html.vim
Normal file
@@ -0,0 +1,673 @@
|
||||
let s:mx = '\([+>]\|[<^]\+\)\{-}\s*'
|
||||
\ .'\((*\)\{-}\s*'
|
||||
\ .'\([@#.]\{-}[a-zA-Z\!][a-zA-Z0-9:_\!\-$]*\|{\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}[ \t\r\n}]*\)'
|
||||
\ .'\('
|
||||
\ .'\%('
|
||||
\ .'\%(#{[{}a-zA-Z0-9_\-\$]\+\|#[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\|\%(\[[^\]]\+\]\)'
|
||||
\ .'\|\%(\.{[{}a-zA-Z0-9_\-\$]\+\|\.[a-zA-Z0-9_\-\$]\+\)'
|
||||
\ .'\)*'
|
||||
\ .'\)'
|
||||
\ .'\%(\({\%([^$}]\+\|\$#\|\${\w\+}\|\$\+\)*}\)\)\{0,1}'
|
||||
\ .'\%(\*\([0-9]\+\)\)\{0,1}'
|
||||
\ .'\(\%()\%(\*[0-9]\+\)\{0,1}\)*\)'
|
||||
|
||||
function! zencoding#lang#html#findTokens(str)
|
||||
let str = a:str
|
||||
let [pos, last_pos] = [0, 0]
|
||||
while 1
|
||||
let tag = matchstr(str, '<[a-zA-Z].\{-}>', pos)
|
||||
if len(tag) == 0
|
||||
break
|
||||
endif
|
||||
let pos = stridx(str, tag, pos) + len(tag)
|
||||
endwhile
|
||||
let last_pos = pos
|
||||
while len(str) > 0
|
||||
let token = matchstr(str, s:mx, pos)
|
||||
if token == ''
|
||||
break
|
||||
endif
|
||||
if token =~ '^\s'
|
||||
let token = matchstr(token, '^\s*\zs.*')
|
||||
let last_pos = stridx(str, token, pos)
|
||||
endif
|
||||
let pos = stridx(str, token, pos) + len(token)
|
||||
endwhile
|
||||
return a:str[last_pos :-1]
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#parseIntoTree(abbr, type)
|
||||
let abbr = a:abbr
|
||||
let type = a:type
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
if !has_key(settings, type)
|
||||
let type = 'html'
|
||||
endif
|
||||
if len(type) == 0 | let type = 'html' | endif
|
||||
|
||||
let settings = zencoding#getSettings()
|
||||
let indent = zencoding#getIndentation(type)
|
||||
|
||||
" try 'foo' to (foo-x)
|
||||
let rabbr = zencoding#getExpandos(type, abbr)
|
||||
if rabbr == abbr
|
||||
" try 'foo+(' to (foo-x)
|
||||
let rabbr = substitute(abbr, '\%(+\|^\)\([a-zA-Z][a-zA-Z0-9+]\+\)+\([(){}>]\|$\)', '\="(".zencoding#getExpandos(type, submatch(1)).")".submatch(2)', 'i')
|
||||
endif
|
||||
let abbr = rabbr
|
||||
|
||||
let root = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
let parent = root
|
||||
let last = root
|
||||
let pos = []
|
||||
while len(abbr)
|
||||
" parse line
|
||||
let match = matchstr(abbr, s:mx)
|
||||
let str = substitute(match, s:mx, '\0', 'ig')
|
||||
let operator = substitute(match, s:mx, '\1', 'ig')
|
||||
let block_start = substitute(match, s:mx, '\2', 'ig')
|
||||
let tag_name = substitute(match, s:mx, '\3', 'ig')
|
||||
let attributes = substitute(match, s:mx, '\4', 'ig')
|
||||
let value = substitute(match, s:mx, '\5', 'ig')
|
||||
let multiplier = 0 + substitute(match, s:mx, '\6', 'ig')
|
||||
let block_end = substitute(match, s:mx, '\7', 'ig')
|
||||
let important = 0
|
||||
if len(str) == 0
|
||||
break
|
||||
endif
|
||||
if tag_name =~ '^#'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if tag_name =~ '.!$'
|
||||
let tag_name = tag_name[:-2]
|
||||
let important = 1
|
||||
endif
|
||||
if tag_name =~ '^\.'
|
||||
let attributes = tag_name . attributes
|
||||
let tag_name = 'div'
|
||||
endif
|
||||
if multiplier <= 0 | let multiplier = 1 | endif
|
||||
|
||||
" make default node
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0, 'important': 0 }
|
||||
let current.name = tag_name
|
||||
|
||||
let current.important = important
|
||||
|
||||
" aliases
|
||||
let aliases = zencoding#getResource(type, 'aliases', {})
|
||||
if has_key(aliases, tag_name)
|
||||
let current.name = aliases[tag_name]
|
||||
endif
|
||||
|
||||
let use_pipe_for_cursor = zencoding#getResource(type, 'use_pipe_for_cursor', 1)
|
||||
|
||||
" snippets
|
||||
let snippets = zencoding#getResource(type, 'snippets', {})
|
||||
if !empty(snippets) && has_key(snippets, tag_name)
|
||||
let snippet = snippets[tag_name]
|
||||
if use_pipe_for_cursor
|
||||
let snippet = substitute(snippet, '|', '${cursor}', 'g')
|
||||
endif
|
||||
let lines = split(snippet, "\n")
|
||||
call map(lines, 'substitute(v:val, "\\( \\|\\t\\)", escape(indent, "\\\\"), "g")')
|
||||
let current.snippet = join(lines, "\n")
|
||||
let current.name = ''
|
||||
endif
|
||||
|
||||
" default_attributes
|
||||
let default_attributes = zencoding#getResource(type, 'default_attributes', {})
|
||||
if !empty(default_attributes)
|
||||
for pat in [current.name, tag_name]
|
||||
if has_key(default_attributes, pat)
|
||||
if type(default_attributes[pat]) == 4
|
||||
let a = default_attributes[pat]
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
else
|
||||
for a in default_attributes[pat]
|
||||
if use_pipe_for_cursor
|
||||
for k in keys(a)
|
||||
let current.attr[k] = len(a[k]) ? substitute(a[k], '|', '${cursor}', 'g') : '${cursor}'
|
||||
endfor
|
||||
else
|
||||
for k in keys(a)
|
||||
let current.attr[k] = a[k]
|
||||
endfor
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
if has_key(settings.html.default_attributes, current.name)
|
||||
let current.name = substitute(current.name, ':.*$', '', '')
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
" parse attributes
|
||||
if len(attributes)
|
||||
let attr = attributes
|
||||
while len(attr)
|
||||
let item = matchstr(attr, '\(\%(\%(#[{}a-zA-Z0-9_\-\$]\+\)\|\%(\[[^\]]\+\]\)\|\%(\.[{}a-zA-Z0-9_\-\$]\+\)*\)\)')
|
||||
if len(item) == 0
|
||||
break
|
||||
endif
|
||||
if item[0] == '#'
|
||||
let current.attr.id = item[1:]
|
||||
endif
|
||||
if item[0] == '.'
|
||||
let current.attr.class = substitute(item[1:], '\.', ' ', 'g')
|
||||
endif
|
||||
if item[0] == '['
|
||||
let atts = item[1:-2]
|
||||
while len(atts)
|
||||
let amat = matchstr(atts, '\(\w\+\%(="[^"]*"\|=''[^'']*''\|[^ ''"\]]*\)\{0,1}\)')
|
||||
if len(amat) == 0
|
||||
break
|
||||
endif
|
||||
let key = split(amat, '=')[0]
|
||||
let val = amat[len(key)+1:]
|
||||
if val =~ '^["'']'
|
||||
let val = val[1:-2]
|
||||
endif
|
||||
let current.attr[key] = val
|
||||
let atts = atts[stridx(atts, amat) + len(amat):]
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(strpart(attr, len(item)), '^\s*', '', '')
|
||||
endwhile
|
||||
endif
|
||||
|
||||
" parse text
|
||||
if tag_name =~ '^{.*}$'
|
||||
let current.name = ''
|
||||
let current.value = tag_name
|
||||
else
|
||||
let current.value = value
|
||||
endif
|
||||
let current.multiplier = multiplier
|
||||
|
||||
" parse step inside/outside
|
||||
if !empty(last)
|
||||
if operator =~ '>'
|
||||
unlet! parent
|
||||
let parent = last
|
||||
let current.parent = last
|
||||
let current.pos = last.pos + 1
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = last.pos
|
||||
endif
|
||||
else
|
||||
let current.parent = parent
|
||||
let current.pos = 1
|
||||
endif
|
||||
if operator =~ '[<^]'
|
||||
for c in range(len(operator))
|
||||
let tmp = parent.parent
|
||||
if empty(tmp)
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
let current.parent = tmp
|
||||
endfor
|
||||
endif
|
||||
|
||||
call add(parent.child, current)
|
||||
let last = current
|
||||
|
||||
" parse block
|
||||
if block_start =~ '('
|
||||
if operator =~ '>'
|
||||
let last.pos += 1
|
||||
endif
|
||||
for n in range(len(block_start))
|
||||
let pos += [last.pos]
|
||||
endfor
|
||||
endif
|
||||
if block_end =~ ')'
|
||||
for n in split(substitute(substitute(block_end, ' ', '', 'g'), ')', ',),', 'g'), ',')
|
||||
if n == ')'
|
||||
if len(pos) > 0 && last.pos >= pos[-1]
|
||||
for c in range(last.pos - pos[-1])
|
||||
let tmp = parent.parent
|
||||
if !has_key(tmp, 'parent')
|
||||
break
|
||||
endif
|
||||
let parent = tmp
|
||||
endfor
|
||||
if len(pos) > 0
|
||||
call remove(pos, -1)
|
||||
endif
|
||||
let last = parent
|
||||
let last.pos += 1
|
||||
endif
|
||||
elseif len(n)
|
||||
let cl = last.child
|
||||
let cls = []
|
||||
for c in range(n[1:])
|
||||
let cls += cl
|
||||
endfor
|
||||
let last.child = cls
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
let abbr = abbr[stridx(abbr, match) + len(match):]
|
||||
|
||||
if g:zencoding_debug > 1
|
||||
echomsg "str=".str
|
||||
echomsg "block_start=".block_start
|
||||
echomsg "tag_name=".tag_name
|
||||
echomsg "operator=".operator
|
||||
echomsg "attributes=".attributes
|
||||
echomsg "value=".value
|
||||
echomsg "multiplier=".multiplier
|
||||
echomsg "block_end=".block_end
|
||||
echomsg "abbr=".abbr
|
||||
echomsg "pos=".string(pos)
|
||||
echomsg "---"
|
||||
endif
|
||||
endwhile
|
||||
return root
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
|
||||
if zencoding#useFilter(filters, 'haml')
|
||||
return zencoding#lang#haml#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
if zencoding#useFilter(filters, 'slim')
|
||||
return zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current_name, '\$$', itemno+1, '')
|
||||
endif
|
||||
|
||||
let str = ''
|
||||
if len(current_name) == 0
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
return text
|
||||
endif
|
||||
if len(current_name) > 0
|
||||
let str .= '<' . current_name
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
endif
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
if zencoding#useFilter(filters, 'c')
|
||||
if attr == 'id' | let comment .= '#' . val | endif
|
||||
if attr == 'class' | let comment .= '.' . val | endif
|
||||
endif
|
||||
endfor
|
||||
if len(comment) > 0
|
||||
let str = "<!-- " . comment . " -->\n" . str
|
||||
endif
|
||||
if stridx(','.settings.html.empty_elements.',', ','.current_name.',') != -1
|
||||
let str .= settings.html.empty_element_suffix
|
||||
else
|
||||
let str .= ">"
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
let str .= text
|
||||
let nc = len(current.child)
|
||||
let dr = 0
|
||||
if nc > 0
|
||||
for n in range(nc)
|
||||
let child = current.child[n]
|
||||
if child.multiplier > 1
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif len(current_name) > 0 && stridx(','.settings.html.inline_elements.',', ','.current_name.',') == -1
|
||||
if nc > 1 || (len(child.name) > 0 && stridx(','.settings.html.inline_elements.',', ','.child.name.',') == -1)
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
elseif current.multiplier == 1 && nc == 1 && len(child.name) == 0
|
||||
echo current.multiplier
|
||||
let str .= "\n" . indent
|
||||
let dr = 1
|
||||
endif
|
||||
endif
|
||||
let inner = zencoding#toString(child, type, 0, filters, itemno)
|
||||
let inner = substitute(inner, "^\n", "", 'g')
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . '$', '', 'g')
|
||||
let str .= inner
|
||||
endfor
|
||||
else
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if dr
|
||||
let str .= "\n"
|
||||
endif
|
||||
let str .= "</" . current_name . ">"
|
||||
endif
|
||||
if len(comment) > 0
|
||||
let str .= "\n<!-- /" . comment . " -->"
|
||||
endif
|
||||
if len(current_name) > 0 && current.multiplier > 0 || stridx(','.settings.html.block_elements.',', ','.current_name.',') != -1
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#imageSize()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = substitute(zencoding#toString(current, 'html', 1), '\n', '', '')
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#encodeImage()
|
||||
let img_region = zencoding#util#searchRegion('<img\s', '>')
|
||||
if !zencoding#util#regionIsValid(img_region) || !zencoding#util#cursorInRegion(img_region)
|
||||
return
|
||||
endif
|
||||
let content = zencoding#util#getContent(img_region)
|
||||
if content !~ '^<img[^><]\+>$'
|
||||
return
|
||||
endif
|
||||
let current = zencoding#lang#html#parseTag(content)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let html = zencoding#toString(current, 'html', 1)
|
||||
call zencoding#util#setContent(img_region, html)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9]*\)\(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\(/\{0,1}\)>'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#toggleComment()
|
||||
let orgpos = getpos('.')
|
||||
let curpos = getpos('.')
|
||||
let mx = '<\%#[^>]*>'
|
||||
while 1
|
||||
let block = zencoding#util#searchRegion('<!--', '-->')
|
||||
if zencoding#util#regionIsValid(block)
|
||||
let block[1][1] += 2
|
||||
let content = zencoding#util#getContent(block)
|
||||
let content = substitute(content, '^<!--\s\(.*\)\s-->$', '\1', '')
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
let block = zencoding#util#searchRegion('<[^>]', '>')
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
let pos1 = searchpos('<', 'bcW')
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
return
|
||||
endif
|
||||
let curpos = getpos('.')
|
||||
continue
|
||||
endif
|
||||
let pos1 = block[0]
|
||||
let pos2 = block[1]
|
||||
let content = zencoding#util#getContent(block)
|
||||
let tag_name = matchstr(content, '^<\zs/\{0,1}[^ \r\n>]\+')
|
||||
if tag_name[0] == '/'
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name[1:] . '>', '', '</' . tag_name[1:] . '>', 'bnW')
|
||||
let pos1 = searchpos('>', 'cneW')
|
||||
let block = [pos2, pos1]
|
||||
elseif tag_name =~ '/$'
|
||||
if !zencoding#util#pointInRegion(orgpos[1:2], block)
|
||||
" it's broken tree
|
||||
call setpos('.', orgpos)
|
||||
let block = zencoding#util#searchRegion('>', '<')
|
||||
let content = '><!-- ' . zencoding#util#getContent(block)[1:-2] . ' --><'
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
else
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos2 = searchpairpos('<'. tag_name . '>', '', '</' . tag_name . '>', 'nW')
|
||||
call setpos('.', [0, pos2[0], pos2[1], 0])
|
||||
let pos2 = searchpos('>', 'cneW')
|
||||
let block = [pos1, pos2]
|
||||
endif
|
||||
if !zencoding#util#regionIsValid(block)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block)
|
||||
let content = '<!-- ' . zencoding#util#getContent(block) . ' -->'
|
||||
call zencoding#util#setContent(block, content)
|
||||
silent! call setpos('.', orgpos)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#balanceTag(flag) range
|
||||
let vblock = zencoding#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let settings = zencoding#getSettings()
|
||||
|
||||
if a:flag > 0
|
||||
while 1
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
else
|
||||
while 1
|
||||
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'W')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||
let pos2 = searchpos('>', 'nW')
|
||||
else
|
||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '>\zs', 'nW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if pos1[0] == 0 && pos1[1] == 0
|
||||
break
|
||||
endif
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#moveNextPrev(flag)
|
||||
let pos = search('\%(</\w\+\)\@<!\zs><\/\|\(""\)\|^\(\s*\)$', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 3
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#splitJoinTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
let content = content[:-3] . "></" . tag_name . '>'
|
||||
call zencoding#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] == '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
let content = matchstr(content, mx)[:-2] . '/>'
|
||||
call zencoding#util#setContent(block, content)
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#html#removeTag()
|
||||
let curpos = getpos('.')
|
||||
while 1
|
||||
let mx = '<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||
let pos1 = searchpos(mx, 'bcnW')
|
||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
||||
if content[-2:] == '/>' && zencoding#util#cursorInRegion(block)
|
||||
call zencoding#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if tag_name[0] == '/'
|
||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
||||
let pos2 = searchpos('</' . tag_name[1:] . '>', 'cneW')
|
||||
else
|
||||
let pos2 = searchpos('</' . tag_name . '>', 'cneW')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
let content = zencoding#util#getContent(block)
|
||||
if zencoding#util#pointInRegion(curpos[1:2], block) && content[1:] !~ '<' . tag_name . '[^a-zA-Z0-9]*[^>]*>'
|
||||
call zencoding#util#setContent(block, '')
|
||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
||||
return
|
||||
else
|
||||
if block[0][0] > 0
|
||||
call setpos('.', [0, block[0][0]-1, block[0][1], 0])
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endwhile
|
||||
endfunction
|
||||
157
autoload/zencoding/lang/sass.vim
Normal file
157
autoload/zencoding/lang/sass.vim
Normal file
@@ -0,0 +1,157 @@
|
||||
function! zencoding#lang#sass#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr == 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= "\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= "\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . indent, 'g')
|
||||
let inner = substitute(inner, "\n" . indent . "$", "", 'g')
|
||||
let str .= indent . inner
|
||||
else
|
||||
let text = zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let text = substitute(text, '\s*;$', '', '')
|
||||
return text
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#parseTag(tag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#moveNextPrev(flag)
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#sass#removeTag()
|
||||
endfunction
|
||||
122
autoload/zencoding/lang/scss.vim
Normal file
122
autoload/zencoding/lang/scss.vim
Normal file
@@ -0,0 +1,122 @@
|
||||
function! zencoding#lang#scss#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseIntoTree(abbr, type)
|
||||
if a:abbr =~ '>'
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
else
|
||||
return zencoding#lang#css#parseIntoTree(a:abbr, a:type)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let str = ""
|
||||
|
||||
let current_name = current.name
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
let tmp = ''
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
if attr == 'id'
|
||||
let str .= '#' . val
|
||||
elseif attr == 'class'
|
||||
let str .= '.' . val
|
||||
else
|
||||
let tmp .= attr . ': ' . val . ';'
|
||||
endif
|
||||
endfor
|
||||
if len(tmp) > 0
|
||||
let str .= " {\n"
|
||||
for line in split(tmp, "\n")
|
||||
let str .= indent . line . "\n"
|
||||
endfor
|
||||
else
|
||||
let str .= " {\n"
|
||||
endif
|
||||
|
||||
let inner = ''
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let str .= indent . inner . "\n}\n"
|
||||
else
|
||||
return zencoding#lang#css#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#imageSize()
|
||||
call zencoding#lang#css#imageSize()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#encodeImage()
|
||||
return zencoding#lang#css#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#parseTag(tag)
|
||||
return zencoding#lang#css#parseTag(a:tag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#toggleComment()
|
||||
call zencoding#lang#css#toggleComment()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#balanceTag(flag) range
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
call setpos('.', curpos)
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
if a:flag < 0
|
||||
let ret = searchpair('}', '', '.\zs{')
|
||||
else
|
||||
let ret = searchpair('{', '', '}', 'bW')
|
||||
endif
|
||||
if ret > 0
|
||||
let pos1 = getpos('.')[1:2]
|
||||
if a:flag < 0
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
else
|
||||
let pos2 = searchpairpos('{', '', '}')
|
||||
endif
|
||||
let block = [pos1, pos2]
|
||||
if zencoding#util#regionIsValid(block)
|
||||
call zencoding#util#selectRegion(block)
|
||||
return
|
||||
endif
|
||||
endif
|
||||
if a:flag == -2 || a:flag == 2
|
||||
silent! exe "normal! gv"
|
||||
else
|
||||
call setpos('.', curpos)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#moveNextPrev(flag)
|
||||
call zencoding#lang#css#moveNextPrev(a:flag)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#splitJoinTag()
|
||||
call zencoding#lang#css#splitJoinTag()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#scss#removeTag()
|
||||
call zencoding#lang#ss#removeTag()
|
||||
endfunction
|
||||
269
autoload/zencoding/lang/slim.vim
Normal file
269
autoload/zencoding/lang/slim.vim
Normal file
@@ -0,0 +1,269 @@
|
||||
function! zencoding#lang#slim#findTokens(str)
|
||||
return zencoding#lang#html#findTokens(a:str)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#parseIntoTree(abbr, type)
|
||||
return zencoding#lang#html#parseIntoTree(a:abbr, a:type)
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#toString(settings, current, type, inline, filters, itemno, indent)
|
||||
let settings = a:settings
|
||||
let current = a:current
|
||||
let type = a:type
|
||||
let inline = a:inline
|
||||
let filters = a:filters
|
||||
let itemno = a:itemno
|
||||
let indent = a:indent
|
||||
let dollar_expr = zencoding#getResource(type, 'dollar_expr', 1)
|
||||
let str = ""
|
||||
|
||||
let comment_indent = ''
|
||||
let comment = ''
|
||||
let current_name = current.name
|
||||
if dollar_expr
|
||||
let current_name = substitute(current.name, '\$$', itemno+1, '')
|
||||
endif
|
||||
if len(current.name) > 0
|
||||
let str .= current_name
|
||||
for attr in keys(current.attr)
|
||||
let val = current.attr[attr]
|
||||
if dollar_expr
|
||||
while val =~ '\$\([^#{]\|$\)'
|
||||
let val = substitute(val, '\(\$\+\)\([^{]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
endwhile
|
||||
endif
|
||||
let attr = substitute(attr, '\$$', itemno+1, '')
|
||||
let str .= ' ' . attr . '="' . val . '"'
|
||||
endfor
|
||||
|
||||
let inner = ''
|
||||
if len(current.value) > 0
|
||||
let str .= "\n"
|
||||
let text = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) == 0
|
||||
let str .= '${cursor}'
|
||||
endif
|
||||
if len(current.child) == 1 && len(current.child[0].name) == 0
|
||||
let str .= "\n"
|
||||
let text = current.child[0].value[1:-2]
|
||||
if dollar_expr
|
||||
let text = substitute(text, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let text = substitute(text, '\${nr}', "\n", 'g')
|
||||
let text = substitute(text, '\\\$', '$', 'g')
|
||||
endif
|
||||
for line in split(text, "\n")
|
||||
let str .= indent . "| " . line . "\n"
|
||||
endfor
|
||||
elseif len(current.child) > 0
|
||||
for child in current.child
|
||||
let inner .= zencoding#toString(child, type, inline, filters, itemno)
|
||||
endfor
|
||||
let inner = substitute(inner, "\n", "\n" . escape(indent, '\'), 'g')
|
||||
let inner = substitute(inner, "\n" . escape(indent, '\') . "$", "", 'g')
|
||||
let str .= "\n" . indent . inner
|
||||
endif
|
||||
else
|
||||
let str = current.value[1:-2]
|
||||
if dollar_expr
|
||||
let str = substitute(str, '\%(\\\)\@\<!\(\$\+\)\([^{#]\|$\)', '\=printf("%0".len(submatch(1))."d", itemno+1).submatch(2)', 'g')
|
||||
let str = substitute(str, '\${nr}', "\n", 'g')
|
||||
let str = substitute(str, '\\\$', '$', 'g')
|
||||
endif
|
||||
endif
|
||||
if str !~ "\n$"
|
||||
let str .= "\n"
|
||||
endif
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#imageSize()
|
||||
let line = getline('.')
|
||||
let current = zencoding#lang#slim#parseTag(line)
|
||||
if empty(current) || !has_key(current.attr, 'src')
|
||||
return
|
||||
endif
|
||||
let fn = current.attr.src
|
||||
if fn =~ '^\s*$'
|
||||
return
|
||||
elseif fn !~ '^\(/\|http\)'
|
||||
let fn = simplify(expand('%:h') . '/' . fn)
|
||||
endif
|
||||
|
||||
let [width, height] = zencoding#util#getImageSize(fn)
|
||||
if width == -1 && height == -1
|
||||
return
|
||||
endif
|
||||
let current.attr.width = width
|
||||
let current.attr.height = height
|
||||
let slim = zencoding#toString(current, 'slim', 1)
|
||||
call setline('.', substitute(matchstr(line, '^\s*') . slim, "\n", "", "g"))
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#encodeImage()
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#parseTag(tag)
|
||||
let current = { 'name': '', 'attr': {}, 'child': [], 'snippet': '', 'multiplier': 1, 'parent': {}, 'value': '', 'pos': 0 }
|
||||
let mx = '\([a-zA-Z][a-zA-Z0-9]*\)\s\+\(.*\)'
|
||||
let match = matchstr(a:tag, mx)
|
||||
let current.name = substitute(match, mx, '\1', 'i')
|
||||
let attrs = substitute(match, mx, '\2', 'i')
|
||||
let mx = '\([a-zA-Z0-9]\+\)=\%(\([^"'' \t]\+\)\|"\([^"]\{-}\)"\|''\([^'']\{-}\)''\)'
|
||||
while len(attrs) > 0
|
||||
let match = matchstr(attrs, mx)
|
||||
if len(match) == 0
|
||||
break
|
||||
endif
|
||||
let attr_match = matchlist(match, mx)
|
||||
let name = attr_match[1]
|
||||
let value = len(attr_match[2]) ? attr_match[2] : attr_match[3]
|
||||
let current.attr[name] = value
|
||||
let attrs = attrs[stridx(attrs, match) + len(match):]
|
||||
endwhile
|
||||
return current
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#toggleComment()
|
||||
let line = getline('.')
|
||||
let space = matchstr(line, '^\s*')
|
||||
if line =~ '^\s*/'
|
||||
call setline('.', space . line[len(space)+1:])
|
||||
elseif line =~ '^\s*[a-z]'
|
||||
call setline('.', space . '/' . line[len(space):])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#balanceTag(flag) range
|
||||
let block = zencoding#util#getVisualBlock()
|
||||
if a:flag == -2 || a:flag == 2
|
||||
let curpos = [0, line("'<"), col("'<"), 0]
|
||||
else
|
||||
let curpos = getpos('.')
|
||||
endif
|
||||
let n = curpos[1]
|
||||
let ml = len(matchstr(getline(n), '^\s*'))
|
||||
|
||||
if a:flag > 0
|
||||
if a:flag == 1 || !zencoding#util#regionIsValid(block)
|
||||
let n = line('.')
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l < ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endif
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
while n > 0
|
||||
let l = len(matchstr(getline(n), '^\s*\ze[a-z]'))
|
||||
if l > 0 && l > ml
|
||||
let ml = l
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
let sn = n
|
||||
if n == 0
|
||||
let ml = 0
|
||||
endif
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
call setpos('.', [0, n, 1, 0])
|
||||
normal! V
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#moveNextPrev(flag)
|
||||
let pos = search('""\|\(^\s*|\s*\zs\)', a:flag ? 'Wpb' : 'Wp')
|
||||
if pos == 2
|
||||
startinsert!
|
||||
elseif pos != 0
|
||||
silent! normal! l
|
||||
startinsert
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#splitJoinTag()
|
||||
let n = line('.')
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
let sn = n
|
||||
let n += 1
|
||||
if getline(n) =~ '^\s*|'
|
||||
while n <= line('$')
|
||||
if getline(n) !~ '^\s*|'
|
||||
break
|
||||
endif
|
||||
exe n "delete"
|
||||
endwhile
|
||||
call setpos('.', [0, sn, 1, 0])
|
||||
else
|
||||
let spaces = matchstr(getline(sn), '^\s*')
|
||||
call append(sn, spaces . ' | ')
|
||||
call setpos('.', [0, sn+1, 1, 0])
|
||||
startinsert!
|
||||
endif
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! zencoding#lang#slim#removeTag()
|
||||
let n = line('.')
|
||||
let ml = 0
|
||||
while n > 0
|
||||
if getline(n) =~ '^\s*\ze[a-z]'
|
||||
let ml = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
break
|
||||
endif
|
||||
let n -= 1
|
||||
endwhile
|
||||
let sn = n
|
||||
while n < line('$')
|
||||
let l = len(matchstr(getline(n), '^\s*[a-z]'))
|
||||
if l > 0 && l <= ml
|
||||
let n -= 1
|
||||
break
|
||||
endif
|
||||
let n += 1
|
||||
endwhile
|
||||
if sn == n
|
||||
exe "delete"
|
||||
else
|
||||
exe sn "," (n-1) "delete"
|
||||
endif
|
||||
endfunction
|
||||
230
autoload/zencoding/util.vim
Normal file
230
autoload/zencoding/util.vim
Normal file
@@ -0,0 +1,230 @@
|
||||
"==============================================================================
|
||||
" region utils
|
||||
"==============================================================================
|
||||
" deleteContent : delete content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin::end
|
||||
" --------------------
|
||||
function! zencoding#util#deleteContent(region)
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
|
||||
call setline(line('.'), lines[0][:a:region[0][1]-2] . lines[-1][a:region[1][1]])
|
||||
endfunction
|
||||
|
||||
" change_content : change content in region
|
||||
" if region make from between '<foo>' and '</foo>'
|
||||
" --------------------
|
||||
" begin:<foo>
|
||||
" </foo>:end
|
||||
" --------------------
|
||||
" and content is
|
||||
" --------------------
|
||||
" foo
|
||||
" bar
|
||||
" baz
|
||||
" --------------------
|
||||
" this function make the content as following
|
||||
" --------------------
|
||||
" begin:foo
|
||||
" bar
|
||||
" baz:end
|
||||
" --------------------
|
||||
function! zencoding#util#setContent(region, content)
|
||||
let newlines = split(a:content, '\n', 1)
|
||||
let oldlines = getline(a:region[0][0], a:region[1][0])
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
silent! exe "delete ".(a:region[1][0] - a:region[0][0])
|
||||
if len(newlines) == 0
|
||||
let tmp = ''
|
||||
if a:region[0][1] > 1
|
||||
let tmp = oldlines[0][:a:region[0][1]-2]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let tmp .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), tmp)
|
||||
elseif len(newlines) == 1
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[0] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
else
|
||||
if a:region[0][1] > 1
|
||||
let newlines[0] = oldlines[0][:a:region[0][1]-2] . newlines[0]
|
||||
endif
|
||||
if a:region[1][1] >= 1
|
||||
let newlines[-1] .= oldlines[-1][a:region[1][1]:]
|
||||
endif
|
||||
call setline(line('.'), newlines[0])
|
||||
call append(line('.'), newlines[1:])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" select_region : select region
|
||||
" this function make a selection of region
|
||||
function! zencoding#util#selectRegion(region)
|
||||
call setpos('.', [0, a:region[1][0], a:region[1][1], 0])
|
||||
normal! v
|
||||
call setpos('.', [0, a:region[0][0], a:region[0][1], 0])
|
||||
endfunction
|
||||
|
||||
" point_in_region : check point is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#pointInRegion(point, region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
if a:region[0][0] > a:point[0] | return 0 | endif
|
||||
if a:region[1][0] < a:point[0] | return 0 | endif
|
||||
if a:region[0][0] == a:point[0] && a:region[0][1] > a:point[1] | return 0 | endif
|
||||
if a:region[1][0] == a:point[0] && a:region[1][1] < a:point[1] | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" cursor_in_region : check cursor is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#cursorInRegion(region)
|
||||
if !zencoding#util#regionIsValid(a:region) | return 0 | endif
|
||||
let cur = getpos('.')[1:2]
|
||||
return zencoding#util#pointInRegion(cur, a:region)
|
||||
endfunction
|
||||
|
||||
" region_is_valid : check region is valid
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#regionIsValid(region)
|
||||
if a:region[0][0] == 0 || a:region[1][0] == 0 | return 0 | endif
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" search_region : make region from pattern which is composing start/end
|
||||
" this function return array of position
|
||||
function! zencoding#util#searchRegion(start, end)
|
||||
return [searchpairpos(a:start, '', a:end, 'bcnW'), searchpairpos(a:start, '\%#', a:end, 'nW')]
|
||||
endfunction
|
||||
|
||||
" get_content : get content in region
|
||||
" this function return string in region
|
||||
function! zencoding#util#getContent(region)
|
||||
if !zencoding#util#regionIsValid(a:region)
|
||||
return ''
|
||||
endif
|
||||
let lines = getline(a:region[0][0], a:region[1][0])
|
||||
if a:region[0][0] == a:region[1][0]
|
||||
let lines[0] = lines[0][a:region[0][1]-1:a:region[1][1]-1]
|
||||
else
|
||||
let lines[0] = lines[0][a:region[0][1]-1:]
|
||||
let lines[-1] = lines[-1][:a:region[1][1]-1]
|
||||
endif
|
||||
return join(lines, "\n")
|
||||
endfunction
|
||||
|
||||
" region_in_region : check region is in the region
|
||||
" this function return 0 or 1
|
||||
function! zencoding#util#regionInRegion(outer, inner)
|
||||
if !zencoding#util#regionIsValid(a:inner) || !zencoding#util#regionIsValid(a:outer)
|
||||
return 0
|
||||
endif
|
||||
return zencoding#util#pointInRegion(a:inner[0], a:outer) && zencoding#util#pointInRegion(a:inner[1], a:outer)
|
||||
endfunction
|
||||
|
||||
" get_visualblock : get region of visual block
|
||||
" this function return region of visual block
|
||||
function! zencoding#util#getVisualBlock()
|
||||
return [[line("'<"), col("'<")], [line("'>"), col("'>")]]
|
||||
endfunction
|
||||
|
||||
"==============================================================================
|
||||
" html utils
|
||||
"==============================================================================
|
||||
function! zencoding#util#getContentFromURL(url)
|
||||
let res = system(printf("%s %s", g:zencoding_curl_command, shellescape(substitute(a:url, '#.*', '', ''))))
|
||||
let s1 = len(split(res, '?'))
|
||||
let utf8 = iconv(res, 'utf-8', &encoding)
|
||||
let s2 = len(split(utf8, '?'))
|
||||
return s2 > s1 * 2 ? utf8 : res
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getTextFromHTML(buf)
|
||||
let threshold_len = 100
|
||||
let threshold_per = 0.1
|
||||
let buf = a:buf
|
||||
|
||||
let buf = strpart(buf, stridx(buf, '</head>'))
|
||||
let buf = substitute(buf, '<style[^>]*>.\{-}</style>', '', 'g')
|
||||
let buf = substitute(buf, '<script[^>]*>.\{-}</script>', '', 'g')
|
||||
let res = ''
|
||||
let max = 0
|
||||
let mx = '\(<td[^>]\{-}>\)\|\(<\/td>\)\|\(<div[^>]\{-}>\)\|\(<\/div>\)'
|
||||
let m = split(buf, mx)
|
||||
for str in m
|
||||
let c = split(str, '<[^>]*?>')
|
||||
let str = substitute(str, '<[^>]\{-}>', ' ', 'g')
|
||||
let str = substitute(str, '>', '>', 'g')
|
||||
let str = substitute(str, '<', '<', 'g')
|
||||
let str = substitute(str, '"', '"', 'g')
|
||||
let str = substitute(str, ''', "'", 'g')
|
||||
let str = substitute(str, ' ', ' ', 'g')
|
||||
let str = substitute(str, '¥', '\¥', 'g')
|
||||
let str = substitute(str, '&', '\&', 'g')
|
||||
let str = substitute(str, '^\s*\(.*\)\s*$', '\1', '')
|
||||
let str = substitute(str, '\s\+', ' ', 'g')
|
||||
let l = len(str)
|
||||
if l > threshold_len
|
||||
let per = (l+0.0) / len(c)
|
||||
if max < l && per > threshold_per
|
||||
let max = l
|
||||
let res = str
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
let res = substitute(res, '^\s*\(.*\)\s*$', '\1', 'g')
|
||||
return res
|
||||
endfunction
|
||||
|
||||
function! zencoding#util#getImageSize(fn)
|
||||
let fn = a:fn
|
||||
if filereadable(fn)
|
||||
let hex = substitute(system('xxd -p "'.fn.'"'), '\n', '', 'g')
|
||||
else
|
||||
let hex = substitute(system(g:zencoding_curl_command.' "'.fn.'" | xxd -p'), '\n', '', 'g')
|
||||
endif
|
||||
|
||||
let [width, height] = [-1, -1]
|
||||
if hex =~ '^89504e470d0a1a0a'
|
||||
let width = eval('0x'.hex[32:39])
|
||||
let height = eval('0x'.hex[40:47])
|
||||
endif
|
||||
if hex =~ '^ffd8'
|
||||
let pos = 4
|
||||
while pos < len(hex)
|
||||
let bs = hex[pos+0:pos+3]
|
||||
let pos += 4
|
||||
if bs == 'ffc0' || bs == 'ffc2'
|
||||
let pos += 6
|
||||
let height = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
let pos += 4
|
||||
let width = eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])
|
||||
break
|
||||
elseif bs =~ 'ffd[9a]'
|
||||
break
|
||||
elseif bs =~ 'ff\(e[0-9a-e]\|fe\|db\|dd\|c4\)'
|
||||
let pos += (eval('0x'.hex[pos+0:pos+1])*256 + eval('0x'.hex[pos+2:pos+3])) * 2
|
||||
endif
|
||||
endwhile
|
||||
endif
|
||||
if hex =~ '^47494638'
|
||||
let width = eval('0x'.hex[14:15].hex[12:13])
|
||||
let height = eval('0x'.hex[18:19].hex[16:17])
|
||||
endif
|
||||
|
||||
return [width, height]
|
||||
endfunction
|
||||
|
||||
429
doc/zencoding.txt
Normal file
429
doc/zencoding.txt
Normal file
@@ -0,0 +1,429 @@
|
||||
*zencoding.txt* ZenCoding for Vim
|
||||
|
||||
-------------------------------------------------------
|
||||
ZenCoding: vim plugins for HTML and CSS hi-speed coding
|
||||
-------------------------------------------------------
|
||||
|
||||
Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
WebSite: http://mattn.kaoriya.net/
|
||||
Repository: http://github.com/mattn/zencoding-vim
|
||||
Site: http://mattn.github.com/zencoding-vim
|
||||
License: BSD style license
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *zencoding-contents*
|
||||
|
||||
Introduction |zencoding-introduction|
|
||||
Install |zencoding-install|
|
||||
Tutorial |zencoding-tutorial|
|
||||
1. Expand Abbreviation |zencoding-expandabbr|
|
||||
2. Wrap with Abbreviation |zencoding-wrap-wtih-abbreviation|
|
||||
3. Balance Tag Inward |zencoding-balance-tag-inward|
|
||||
4. Balance Tag Outward |zencoding-balance-tag-outward|
|
||||
5. Go to Next Edit Point |zencoding-goto-next-point| |<C-Y>n|
|
||||
6. Go to Previous Edit Point |zencoding-goto-previous-point|
|
||||
7. Update <img> Size |zencoding-update-image-size|
|
||||
8. Merge Lines |zencoding-merge-lines|
|
||||
9. Remove Tag |zencoding-remove-tag|
|
||||
10. Split/Join Tag |zencoding-split-join-tag|
|
||||
11. Toggle Comment |zencoding-toggle-comment|
|
||||
12. Make anchor from URL |zencoding-make-anchor-url|
|
||||
13. Make quoted text from URL |zencoding-quoted-text-url|
|
||||
14. Code Pretty |zencoding-code-pretty|
|
||||
Customize |zencoding-customize|
|
||||
1. Key Mappings |zencoding-customize-keymappings|
|
||||
2. Indent Size |zencoding-indent-size|
|
||||
3. Define Tag's Behavior |zencoding-define-tags-behavior|
|
||||
4. Complete Tag |zencoding-complete-tag|
|
||||
Links |zencoding-links|
|
||||
ToDo |zencoding-todo|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *zencoding-introduction* *zencoding*
|
||||
|
||||
|ZenCoding| is an editor plugin for high-speed HTML, XML, XSL (or any other
|
||||
structured code format) coding and editing. The core of this plugin is a
|
||||
powerful abbreviation engine which allows you to expand expressions?similar to
|
||||
CSS selectors?into HTML code:
|
||||
>
|
||||
div#page>div.logo+ul#navigation>li*5>a
|
||||
<
|
||||
...can be expanded into:
|
||||
>
|
||||
<div id="page">
|
||||
<div class="logo"></div>
|
||||
<ul id="navigation">
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
<li><a href=""></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<
|
||||
Read more about current Zen Coding syntax
|
||||
http://code.google.com/p/zen-coding/wiki/ZenHTMLSelectorsEn
|
||||
|
||||
Abbreviation engine has a modular structure which allows you to expand
|
||||
abbreviations into different languages. Zen Coding currently supports CSS,
|
||||
HTML, XML/XSL and HAML, Slim languages via filters.
|
||||
|
||||
==============================================================================
|
||||
INSTALL *zencoding-install*
|
||||
|
||||
Install the distributed files into Vim runtime directory which is usually
|
||||
~/.vim/, or $HOME/vimfiles on Windows.
|
||||
|
||||
If you install pathogen that provided from Tim Pope, you should extract the
|
||||
file into 'bundle' directory.
|
||||
|
||||
==============================================================================
|
||||
TUTORIAL *zencoding-tutorial*
|
||||
|
||||
If you are seeing this file as :help, then you can't edit this file.
|
||||
You should copy this section and create new buffer, paste and write as
|
||||
'zencoding-tutor.txt'. Formally, open the file to start tutorial.
|
||||
|
||||
1. Expand Abbreviation *zencoding-expandabbr* *<C-Y>,*
|
||||
|
||||
Type abbreviation as 'div>p#foo$*3>a' and type |<C-Y>,|.
|
||||
>
|
||||
<div>
|
||||
<p id="foo1">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo2">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
<p id="foo3">
|
||||
<a href=""></a>
|
||||
</p>
|
||||
</div>
|
||||
<
|
||||
2. Wrap with Abbreviation *zencoding-wrap-wtih-abbreviation* *v_<C-Y>,*
|
||||
|
||||
Write as below.
|
||||
>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
<
|
||||
Then do visual select(line wize) and type |<C-Y>,|.
|
||||
If you request 'Tag:', then type 'ul>li*'.
|
||||
>
|
||||
<ul>
|
||||
<li>test1</li>
|
||||
<li>test2</li>
|
||||
<li>test3</li>
|
||||
</ul>
|
||||
<
|
||||
If you type tag as 'blockquote', then you'll see as following.
|
||||
>
|
||||
<blockquote>
|
||||
test1
|
||||
test2
|
||||
test3
|
||||
</blockquote>
|
||||
<
|
||||
3. Balance Tag Inward *zencoding-balance-tag-inward* *<C-Y>d*
|
||||
|
||||
To select inward of ul tag, type |<C-Y>d| in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>d| select from begin of <ul> to end of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
4. Balance Tag Outward *zencoding-balance-tag-outward* *<C-Y>D*
|
||||
|
||||
To select outward of ul tag, insert mode, type <C-Y>D in insert mode.
|
||||
>
|
||||
<ul>
|
||||
* <li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>D| select from next letter of <ul> to previous
|
||||
letter of </ul>.
|
||||
If cursor is at first of <li>, it select <li class="list1"></li>.
|
||||
|
||||
5. Go to Next Edit Point *zencoding-goto-next-point* *<C-Y>n*
|
||||
|
||||
To jump next point that need to edit, type |<C-Y>n| in insert mode.
|
||||
>
|
||||
* <div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li>
|
||||
<
|
||||
If cursor is at '*', |<C-Y>n| move a cursor into attribute value of div
|
||||
specified id as 'foo'. And type again |<C-Y>n| move a cursor into inner of
|
||||
div specified id as 'bar'.
|
||||
|
||||
6. Go to Previous Edit Point *zencoding-goto-previous-point* *<C-Y>N*
|
||||
|
||||
To jump previous point that need to edit, type |<C-Y>N| in insert mode.
|
||||
>
|
||||
<div id="foo" class="">foo</div>
|
||||
<div id="bar" class="bar"></li> *
|
||||
<
|
||||
If cursor is at '*', |<C-Y>N| move a cursor into div specified id as 'bar'.
|
||||
And type again |<C-Y>N| move a cursor into attribute value of 'foo'.
|
||||
|
||||
7. Update <img> Size *zencoding-update-image-size* *<C-Y>i*
|
||||
|
||||
To expand or update size of image, type |<C-Y>i| on img tag
|
||||
>
|
||||
<img src="foo.png" />
|
||||
<
|
||||
Type '<c-y>i' on img tag
|
||||
>
|
||||
<img src="foo.png" width="32" height="32" />
|
||||
<
|
||||
If you change image, then type it again. it will be following.
|
||||
>
|
||||
<img src="foo-48.png" width="32" height="48" />
|
||||
<
|
||||
8. Merge Lines *zencoding-merge-lines*
|
||||
|
||||
To join multi line text like following, type |J|.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li>
|
||||
<li class="list2"></li>
|
||||
<li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
If you select part of line include <li> and type |<C-Y>m|, it will be
|
||||
following.
|
||||
>
|
||||
<ul>
|
||||
<li class="list1"></li><li class="list2"></li><li class="list3"></li>
|
||||
</ul>
|
||||
<
|
||||
9. Remove Tag *zencoding-remove-tag* *<C-Y>k*
|
||||
|
||||
To remove tag in the block, type |<C-Y>k|.
|
||||
>
|
||||
<div class="foo">
|
||||
<a>cursor is here</a>
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>k| in insert mode, then
|
||||
>
|
||||
<div class="foo">
|
||||
|
||||
</div>
|
||||
<
|
||||
And type |<C-Y>k| in there again, then div will be removed.
|
||||
|
||||
10. Split/Join Tag *zencoding-split-join-tag* *<C-Y>j*
|
||||
|
||||
To join block, type |<C-Y>j|.
|
||||
>
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
<
|
||||
Type |<C-Y>j| in insert mode. then,
|
||||
>
|
||||
<div class="foo"/>
|
||||
<
|
||||
And type |<C-Y>j| in there again.
|
||||
>
|
||||
<div class="foo">
|
||||
</div>
|
||||
<
|
||||
11. Toggle Comment *zencoding-toggle-comment* *<C-Y>/*
|
||||
|
||||
Move cursor to block
|
||||
>
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
<
|
||||
Type '<c-y>/' in insert mode.
|
||||
>
|
||||
<!-- <div>
|
||||
hello world
|
||||
</div> -->
|
||||
<
|
||||
Type '<c-y>/' in there again.
|
||||
>
|
||||
<div>
|
||||
hello world
|
||||
</div>
|
||||
<
|
||||
12. Make anchor from URL *zencoding-make-anchor-url* *<C-Y>a*
|
||||
|
||||
Move cursor to URL
|
||||
>
|
||||
http://www.google.com/
|
||||
<
|
||||
Type |<C-Y>a|
|
||||
>
|
||||
<a href="http://www.google.com/">Google</a>
|
||||
<
|
||||
13. Make quoted text from URL *zencoding-quoted-text-url* *<C-Y>A*
|
||||
|
||||
Move cursor to URL
|
||||
>
|
||||
http://github.com/
|
||||
<
|
||||
Type |<C-Y>A|
|
||||
>
|
||||
<blockquote class="quote">
|
||||
<a href="http://github.com/">Secure source code hosting and collaborative development - GitHub</a><br />
|
||||
<p>How does it work? Get up and running in seconds by forking a project, pushing an existing repository...</p>
|
||||
<cite>http://github.com/</cite>
|
||||
</blockquote>
|
||||
<
|
||||
14. Code Pretty *zencoding-code-pretty* *<C-Y>c*
|
||||
|
||||
Select code block, for example select following code from "int main()".
|
||||
>
|
||||
<p>Writing in C language</p>
|
||||
|
||||
int main() {
|
||||
puts("hello world");
|
||||
}
|
||||
<
|
||||
Type |<C-Y>c|
|
||||
>
|
||||
<p>Writing in C language</p>
|
||||
|
||||
<span class="Type">int</span> main() {<br />
|
||||
puts(<span class="Constant">"hello world"</span>);<br />
|
||||
}<br />
|
||||
<
|
||||
==============================================================================
|
||||
CUSTOMIZE *zencoding-customize*
|
||||
|
||||
1. Key Mapping *zencoding-customize-keymappings*
|
||||
|
||||
To specify leading key for expanding or balance tag, or for all,
|
||||
Add this line in your vimrc: >
|
||||
>
|
||||
let g:user_zen_leader_key = '<c-y>'
|
||||
<
|
||||
Or if you prefer to map for each actions, then you set each variables.
|
||||
|
||||
'user_zen_expandabbr_key'
|
||||
'user_zen_expandword_key'
|
||||
'user_zen_balancetaginward_key'
|
||||
'user_zen_balancetagoutward_key'
|
||||
'user_zen_next_key'
|
||||
'user_zen_prev_key'
|
||||
'user_zen_imagesize_key'
|
||||
'user_zen_togglecomment_key'
|
||||
'user_zen_splitjointag_key'
|
||||
'user_zen_removetag_key'
|
||||
'user_zen_anchorizeurl_key'
|
||||
'user_zen_anchorizesummary_key'
|
||||
|
||||
2. Indent Size *zencoding-indent-size*
|
||||
|
||||
To change indent size of html, add this code in your vimrc.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'html' : {
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
If you prefer to change global indent size then add this.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'indentation' : ' '
|
||||
\}
|
||||
<
|
||||
3. Define Tag's Behavior *zencoding-define-tags-behavior*
|
||||
|
||||
zencoding.vim can change behavior of expanding abbreviation for each
|
||||
filetypes as |Dictionary|. for details, see official site of zencoding.
|
||||
for example, vimmer can add following.
|
||||
>
|
||||
let g:user_zen_settings = {
|
||||
\ 'lang' : 'ja',
|
||||
\ 'html' : {
|
||||
\ 'filters' : 'html',
|
||||
\ 'indentation' : ' '
|
||||
\ },
|
||||
\ 'perl' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'aliases' : {
|
||||
\ 'req' : "require '|'"
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'w' : "warn \"${cursor}\";",
|
||||
\ },
|
||||
\ },
|
||||
\ 'php' : {
|
||||
\ 'extends' : 'html',
|
||||
\ 'filters' : 'html,c',
|
||||
\ },
|
||||
\ 'css' : {
|
||||
\ 'filters' : 'fc',
|
||||
\ },
|
||||
\ 'javascript' : {
|
||||
\ 'snippets' : {
|
||||
\ 'jq' : "$(function() {\n\t${cursor}${child}\n});",
|
||||
\ 'jq:each' : "$.each(arr, function(index, item)\n\t${child}\n});",
|
||||
\ 'fn' : "(function() {\n\t${cursor}\n})();",
|
||||
\ 'tm' : "setTimeout(function() {\n\t${cursor}\n}, 100);",
|
||||
\ },
|
||||
\ },
|
||||
\ 'java' : {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'snippets' : {
|
||||
\ 'main': "public static void main(String[] args) {\n\t|\n}",
|
||||
\ 'println': "System.out.println(\"|\");",
|
||||
\ 'class': "public class | {\n}\n",
|
||||
\ },
|
||||
\ },
|
||||
\}
|
||||
<
|
||||
4. Complete Tag *zencoding-complete-tag*
|
||||
|
||||
If you want to complete tags using |omnifunc| then add this.
|
||||
>
|
||||
let g:use_zen_complete_tag = 1
|
||||
<
|
||||
==============================================================================
|
||||
LINKS *zencoding-links*
|
||||
|
||||
zen-coding official site:
|
||||
http://code.google.com/p/zen-coding/
|
||||
|
||||
zencoding.vim:
|
||||
http://mattn.github.com/zencoding-vim
|
||||
|
||||
development repository:
|
||||
https://github.com/mattn/zencoding-vim
|
||||
|
||||
my blog posts about zencoding-vim:
|
||||
http://mattn.kaoriya.net/software/vim/20100222103327.htm
|
||||
http://mattn.kaoriya.net/software/vim/20100306021632.htm
|
||||
|
||||
japanese blog posts about zencoding-vim:
|
||||
http://d.hatena.ne.jp/idesaku/20100424/1272092255
|
||||
http://d.hatena.ne.jp/griefworker/20110118/vim_zen_coding
|
||||
http://d.hatena.ne.jp/sakurako_s/20110126/1295988873
|
||||
http://looxu.blogspot.jp/2010/02/zencodingvimhtml.html
|
||||
|
||||
tutorial traslated in chinese:
|
||||
http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html
|
||||
|
||||
==============================================================================
|
||||
TODO *zencoding-todo*
|
||||
* wrapping inline selected.
|
||||
* more documents.
|
||||
* more contributor.
|
||||
* more time to improve zencodig.vim.
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0:
|
||||
85
index.html
85
index.html
@@ -1,85 +0,0 @@
|
||||
<!doctype html>
|
||||
<head>
|
||||
<title>Emmet.vim</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="static/css/style-sites.css" type="text/css" />
|
||||
<!--[if IE]>
|
||||
<script type="text/javascript">
|
||||
document.createElement('header');
|
||||
document.createElement('section');
|
||||
document.createElement('nav');
|
||||
document.createElement('aside');
|
||||
document.createElement('footer');
|
||||
document.createElement('article');
|
||||
</script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<img id="logo" src="static/images/emmet-vim-logo.png" title="禅" alt="禅" />
|
||||
<h2>vim plugins for HTML and CSS hi-speed coding.</h2>
|
||||
<section id="content">
|
||||
<div class="blocked-content">
|
||||
<article id="whats">
|
||||
<h2 class="maintitle">Whats</h2>
|
||||
<p>emmet for vim</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="install">
|
||||
<h2 class="maintitle">Install</h2>
|
||||
<p>copy plugin/emmet.vim to plugin directory. and copy autoload/emmet.vim to autoload directory.</p>
|
||||
<pre class="code">
|
||||
# cp -r plugin ~/.vim/.
|
||||
# cp -r autoload ~/.vim/.
|
||||
</pre>
|
||||
<p>if you install <a href="http://www.vim.org/scripts/script.php?script_id=2332">pathogen.vim</a>, you can make it work with only copying emmet-vim directory to bundle directory.</p>
|
||||
<pre class="code">
|
||||
# cp -r emmet-vim ~/.vim/bundle/.
|
||||
</pre>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="howworkthis">
|
||||
<h2 class="maintitle">How This Work</h2>
|
||||
<p>below is a movie when using emmet.vim</p>
|
||||
<script type="text/javascript" src="https://asciinema.org/a/4568.js" id="asciicast-4568" async></script>
|
||||
</div>
|
||||
<!--
|
||||
<embed type="application/x-shockwave-flash" src="http://ttyshare.com/t/a474271fe4eea14f6302286d2bfabd968fb40868" width="480" height="288"/>
|
||||
<embed type="application/x-shockwave-flash" src="http://ttyshare.com/t/8e83a40b6e5d6590b2832fc406114dbe348fc96f" width="480" height="288"/>
|
||||
-->
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="repo">
|
||||
<h2 class="maintitle">Repository</h2>
|
||||
<p>
|
||||
<a href="http://github.com/mattn/emmet-vim/">http://github.com/mattn/emmet-vim/</a>
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="license">
|
||||
<h2 class="maintitle">License</h2>
|
||||
<p>BSD style license.</p>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
<div class="blocked-content">
|
||||
<article id="author">
|
||||
<h2 class="maintitle">Author</h2>
|
||||
<p>Project authors:</p>
|
||||
<div>
|
||||
<ul>
|
||||
<li><a href="http://mattn.kaoriya.net/" rel="me">Yasuhiro Matsumoto</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<br />
|
||||
</section>
|
||||
</body>
|
||||
149
plugin/zencoding.vim
Normal file
149
plugin/zencoding.vim
Normal file
@@ -0,0 +1,149 @@
|
||||
"=============================================================================
|
||||
" File: zencoding.vim
|
||||
" Author: Yasuhiro Matsumoto <mattn.jp@gmail.com>
|
||||
" Last Change: 02-Nov-2012.
|
||||
" Version: 0.80
|
||||
" WebPage: http://github.com/mattn/zencoding-vim
|
||||
" Description: vim plugins for HTML and CSS hi-speed coding.
|
||||
" SeeAlso: http://code.google.com/p/zen-coding/
|
||||
" Usage:
|
||||
"
|
||||
" This is vim script support expanding abbreviation like zen-coding.
|
||||
" ref: http://code.google.com/p/zen-coding/
|
||||
"
|
||||
" Type abbreviation
|
||||
" +-------------------------------------
|
||||
" | html:5_
|
||||
" +-------------------------------------
|
||||
" "_" is a cursor position. and type "<c-y>," (Ctrl+y and Comma)
|
||||
" NOTE: Don't worry about key map. you can change it easily.
|
||||
" +-------------------------------------
|
||||
" | <!DOCTYPE HTML>
|
||||
" | <html lang="en">
|
||||
" | <head>
|
||||
" | <title></title>
|
||||
" | <meta charset="UTF-8">
|
||||
" | </head>
|
||||
" | <body>
|
||||
" | _
|
||||
" | </body>
|
||||
" | </html>
|
||||
" +-------------------------------------
|
||||
" Type following
|
||||
" +-------------------------------------
|
||||
" | div#foo$*2>div.bar
|
||||
" +-------------------------------------
|
||||
" And type "<c-y>,"
|
||||
" +-------------------------------------
|
||||
" |<div id="foo1">
|
||||
" | <div class="bar">_</div>
|
||||
" |</div>
|
||||
" |<div id="foo2">
|
||||
" | <div class="bar"></div>
|
||||
" |</div>
|
||||
" +-------------------------------------
|
||||
"
|
||||
" Tips:
|
||||
"
|
||||
" You can customize behavior of expanding with overriding config.
|
||||
" This configuration will be marged at loading plugin.
|
||||
"
|
||||
" let g:user_zen_settings = {
|
||||
" \ 'indentation' : ' ',
|
||||
" \ 'perl' : {
|
||||
" \ 'aliases' : {
|
||||
" \ 'req' : 'require '
|
||||
" \ },
|
||||
" \ 'snippets' : {
|
||||
" \ 'use' : "use strict\nuse warnings\n\n",
|
||||
" \ 'warn' : "warn \"|\";",
|
||||
" \ }
|
||||
" \ }
|
||||
" \}
|
||||
"
|
||||
" You can set language attribute in html using 'zen_settings.lang'.
|
||||
"
|
||||
" GetLatestVimScripts: 2981 1 :AutoInstall: zencoding.vim
|
||||
" script type: plugin
|
||||
|
||||
if &cp || (exists('g:loaded_zencoding_vim') && g:loaded_zencoding_vim)
|
||||
finish
|
||||
endif
|
||||
let g:loaded_zencoding_vim = 1
|
||||
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:zencoding_debug')
|
||||
let g:zencoding_debug = 0
|
||||
endif
|
||||
|
||||
if !exists('g:zencoding_curl_command')
|
||||
let g:zencoding_curl_command = 'curl -s -L -A Mozilla/5.0'
|
||||
endif
|
||||
|
||||
if exists('g:use_zen_complete_tag') && g:use_zen_complete_tag
|
||||
setlocal omnifunc=zencoding#CompleteTag
|
||||
endif
|
||||
|
||||
if !exists('g:user_zen_leader_key')
|
||||
let g:user_zen_leader_key = '<c-y>'
|
||||
endif
|
||||
|
||||
function! s:install_plugin()
|
||||
for item in [
|
||||
\ {'mode': 'i', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandAbbr', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(0,"")<cr>a'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandVisual', 'func': ':call zencoding#expandAbbr(2,"")<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_expandabbr_key', 'key': ',', 'plug': 'ZenCodingExpandNormal', 'func': ':call zencoding#expandAbbr(3,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_expandword_key', 'key': ';', 'plug': 'ZenCodingExpandWord', 'func': '<c-g>u<esc>:call zencoding#expandAbbr(1,"")<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_expandword_key', 'key': ',', 'plug': 'ZenCodingExpandWord', 'func': ':call zencoding#expandAbbr(1,"")<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardInsert', 'func': '<esc>:call zencoding#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardNormal', 'func': ':call zencoding#balanceTag(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_balancetaginward_key', 'key': 'd', 'plug': 'ZenCodingBalanceTagInwardVisual', 'func': ':call zencoding#balanceTag(2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardInsert', 'func': '<esc>:call zencoding#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardNormal', 'func': ':call zencoding#balanceTag(-1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_balancetagoutward_key', 'key': 'D', 'plug': 'ZenCodingBalanceTagOutwardVisual', 'func': ':call zencoding#balanceTag(-2)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': '<esc>:call zencoding#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_next_key', 'key': 'n', 'plug': 'ZenCodingNext', 'func': ':call zencoding#moveNextPrev(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': '<esc>:call zencoding#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_prev_key', 'key': 'N', 'plug': 'ZenCodingPrev', 'func': ':call zencoding#moveNextPrev(1)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': '<esc>:call zencoding#imageSize()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_imagesize_key', 'key': 'i', 'plug': 'ZenCodingImageSize', 'func': ':call zencoding#imageSize()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': '<esc>:call zencoding#toggleComment()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zencoding#toggleComment()<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_mergelines_key', 'key': 'm', 'plug': 'ZenCodingMergeLines', 'func': ':call zencoding#mergeLines()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagInsert', 'func': '<esc>:call zencoding#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTagNormal', 'func': ':call zencoding#splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': '<esc>:call zencoding#removeTag()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zencoding#removeTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': '<esc>:call zencoding#anchorizeURL(0)<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_anchorizeurl_key', 'key': 'a', 'plug': 'ZenCodingAnchorizeURL', 'func': ':call zencoding#anchorizeURL(0)<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': '<esc>:call zencoding#anchorizeURL(1)<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_anchorizesummary_key', 'key': 'A', 'plug': 'ZenCodingAnchorizeSummary', 'func': ':call zencoding#anchorizeURL(1)<cr>'},
|
||||
\ {'mode': 'v', 'var': 'user_zen_codepretty_key', 'key': 'c', 'plug': 'ZenCodingCodePretty', 'func': ':call zencoding#codePretty()<cr>'},
|
||||
\]
|
||||
|
||||
if !hasmapto('<plug>'.item.plug, item.mode)
|
||||
exe item.mode . 'noremap <plug>' . item.plug . ' ' . item.func
|
||||
endif
|
||||
if !exists('g:' . item.var)
|
||||
endif
|
||||
if exists('g:' . item.var)
|
||||
let key = eval('g:' . item.var)
|
||||
else
|
||||
let key = g:user_zen_leader_key . item.key
|
||||
endif
|
||||
if len(maparg(key, item.mode)) == 0
|
||||
exe item.mode . 'map <unique> ' . key . ' <plug>' . item.plug
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
call s:install_plugin()
|
||||
delfunction s:install_plugin
|
||||
|
||||
command! -nargs=1 Zen call zencoding#expandAbbr(4, <q-args>)
|
||||
|
||||
let &cpo = s:save_cpo
|
||||
unlet s:save_cpo
|
||||
|
||||
" vim:set et:
|
||||
@@ -1,99 +0,0 @@
|
||||
@charset "utf-8"
|
||||
|
||||
section, article, aside, hgroup, header, footer, nav, figure { display: block; }
|
||||
|
||||
body {
|
||||
font-family: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", Meiryo, "メイリオ", "MS Pゴシック", Verdana, Geneva, Arial, Helvetica;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
section {
|
||||
clear:both;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
article {
|
||||
}
|
||||
|
||||
img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
#content {
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Verdana', 'Arial';
|
||||
padding: 0.5em; margin-top: 0; margin-bottom: 0;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
background: transparent url(../images/allow-right-orange.png) no-repeat scroll 0%;
|
||||
padding-left: 26px;
|
||||
line-height: 26px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.maintitle {
|
||||
background: transparent url(../images/allow-right-green.png) no-repeat scroll 0%;
|
||||
padding-left: 26px;
|
||||
line-height: 26px;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.blocked-content {
|
||||
padding: 1em;
|
||||
border: 1px dotted gray;
|
||||
font-family: 'Verdana', 'Arial';
|
||||
}
|
||||
|
||||
a{
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:link {
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #006699;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #006699;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
li a, h3 a {
|
||||
padding-left:5px;
|
||||
padding-right:5px;
|
||||
background-color:none;
|
||||
text-decoration:none;
|
||||
color: #333333;
|
||||
text-shadow:1px 1px 1px #ffffff;
|
||||
line-height: 25px;
|
||||
}
|
||||
li a:hover, li a:active, h3 a:hover, li a:active {
|
||||
background-color:#334d55;
|
||||
text-decoration:none;
|
||||
color:#ffffff;
|
||||
text-shadow:1px 1px 1px #000000;
|
||||
}
|
||||
|
||||
pre.code {
|
||||
padding: 1em;
|
||||
border: 1px dotted gray;
|
||||
font-family: 'Verdana', 'Arial';
|
||||
color: white;
|
||||
background: gray;
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
#tty {
|
||||
font-family: monospace;
|
||||
font-size: 10pt;
|
||||
line-height: 0px;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 673 B |
Binary file not shown.
|
Before Width: | Height: | Size: 978 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.1 KiB |
3549
static/js/jquery-latest.js
vendored
3549
static/js/jquery-latest.js
vendored
File diff suppressed because it is too large
Load Diff
782
unittest.vim
Normal file
782
unittest.vim
Normal file
@@ -0,0 +1,782 @@
|
||||
let s:sfile = expand('<sfile>')
|
||||
|
||||
function! s:reload(d)
|
||||
exe "so" a:d."/plugin/zencoding.vim"
|
||||
for f in split(globpath(a:d, 'autoload/**/*.vim'), "\n")
|
||||
silent! exe "so" f
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:show_type(type)
|
||||
echohl Search | echon "[" a:type "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_category(category)
|
||||
echohl MatchParen | echon "[" a:category "]\n" | echohl None
|
||||
echo "\r"
|
||||
endfunction
|
||||
|
||||
function! s:show_pass(pass)
|
||||
echohl Title | echo "pass".a:pass."\n" | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:show_done()
|
||||
echohl IncSearch | echo "done" | echohl None
|
||||
endfunction
|
||||
|
||||
function! s:escape(str)
|
||||
let str = a:str
|
||||
let str = substitute(str, "\n", '\\n', 'g')
|
||||
let str = substitute(str, "\t", '\\t', 'g')
|
||||
return str
|
||||
endfunction
|
||||
|
||||
function! s:show_title(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl MoreMsg | echon "\rtesting #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
endfunction
|
||||
|
||||
function! s:show_skip(no, title)
|
||||
let title = s:escape(a:title)
|
||||
let width = &columns - 23
|
||||
echohl WarningMsg | echon "\rskipped #".printf("%03d", a:no)
|
||||
echohl None | echon ": " . (len(title) < width ? (title.repeat(' ', width-len(title))) : strpart(title, 0, width)) . ' ... '
|
||||
echo ""
|
||||
endfunction
|
||||
|
||||
function! s:show_ok()
|
||||
echohl Title | echon "ok\n" | echohl None
|
||||
echo ""
|
||||
endfunction
|
||||
|
||||
function! s:show_ng(no, expect, got)
|
||||
echohl WarningMsg | echon "ng\n" | echohl None
|
||||
echohl ErrorMsg | echo "failed test #".a:no | echohl None
|
||||
set more
|
||||
echohl WarningMsg | echo printf("expect(%d):", len(a:expect)) | echohl None
|
||||
echo join(split(a:expect, "\n", 1), "|\n")
|
||||
echohl WarningMsg | echo printf("got(%d):", len(a:got)) | echohl None
|
||||
echo join(split(a:got, "\n", 1), "|\n")
|
||||
let cs = split(a:expect, '\zs')
|
||||
for c in range(len(cs))
|
||||
if c < len(a:got)
|
||||
if a:expect[c] != a:got[c]
|
||||
echohl WarningMsg | echo "differ at:" | echohl None
|
||||
echo a:expect[c :-1]
|
||||
break
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
echo ""
|
||||
throw "stop"
|
||||
endfunction
|
||||
|
||||
function! s:test(...)
|
||||
let type = get(a:000, 0, '')
|
||||
let name = get(a:000, 1, '')
|
||||
let index = get(a:000, 2, '')
|
||||
|
||||
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||
for testgroup in testgroups
|
||||
if len(type) > 0 && testgroup.type != type | continue | endif
|
||||
call s:show_type(testgroup.type)
|
||||
for category in testgroup.categories
|
||||
if len(name) > 0 && substitute(category.name,' ','_','g') != name | continue | endif
|
||||
call s:show_category(category.name)
|
||||
let tests = category.tests
|
||||
let start = reltime()
|
||||
for n in range(len(tests))
|
||||
if len(index) > 0 && n != index | continue | endif
|
||||
let query = tests[n].query
|
||||
let result = tests[n].result
|
||||
if has_key(tests[n], 'skip') && tests[n].skip != 0
|
||||
call s:show_skip(n+1, query)
|
||||
continue
|
||||
endif
|
||||
if stridx(query, '$$$$') != -1
|
||||
silent! 1new
|
||||
silent! exe "setlocal ft=".testgroup.type
|
||||
silent! let key = matchstr(query, '.*\$\$\$\$\zs.*\ze\$\$\$\$')
|
||||
if len(key) > 0
|
||||
exe printf('let key = "%s"', key)
|
||||
else
|
||||
let key = "\<c-y>,"
|
||||
endif
|
||||
silent! let query = substitute(query, '\$\$\$\$.*\$\$\$\$', '$$$$', '')
|
||||
silent! call setline(1, split(query, "\n"))
|
||||
let cmd = "normal gg0/\\$\\$\\$\\$\ri\<del>\<del>\<del>\<del>".key
|
||||
if stridx(result, '$$$$') != -1
|
||||
let cmd .= '$$$$'
|
||||
endif
|
||||
silent! exe cmd
|
||||
unlet! res | let res = join(getline(1, line('$')), "\n")
|
||||
silent! bw!
|
||||
call s:show_title(n+1, query)
|
||||
else
|
||||
call s:show_title(n+1, query)
|
||||
unlet! res | let res = zencoding#ExpandWord(query, testgroup.type, 0)
|
||||
endif
|
||||
if stridx(result, '$$$$') != -1
|
||||
if res ==# result
|
||||
call s:show_ok()
|
||||
else
|
||||
call s:show_ng(n+1, result, res)
|
||||
endif
|
||||
else
|
||||
if res ==# result
|
||||
call s:show_ok()
|
||||
else
|
||||
call s:show_ng(n+1, result, res)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
call s:show_pass(reltimestr(reltime(start)))
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
function! s:do_tests(...)
|
||||
try
|
||||
if exists('g:user_zen_settings')
|
||||
let s:old_user_zen_settings = g:user_zen_settings
|
||||
let g:user_zen_settings = { 'indentation': "\t" }
|
||||
endif
|
||||
let oldmore = &more
|
||||
call s:reload(fnamemodify(s:sfile, ':h'))
|
||||
let &more = 0
|
||||
call call('s:test', a:000)
|
||||
call s:show_done()
|
||||
catch
|
||||
echohl ErrorMsg | echomsg v:exception | echohl None
|
||||
finally
|
||||
let &more=oldmore
|
||||
if exists('g:user_zen_settings')
|
||||
let g:user_zen_settings = s:old_user_zen_settings
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! g:zencoding_unittest_complete(arglead, cmdline, cmdpos)
|
||||
let args = split(a:cmdline, '\s\+', 1)
|
||||
let testgroups = eval(join(filter(split(substitute(join(readfile(s:sfile), "\n"), '.*\nfinish\n', '', ''), '\n', 1), "v:val !~ '^\"'")))
|
||||
try
|
||||
if len(args) == 2
|
||||
return filter(map(testgroups, 'v:val.type'), 'stridx(v:val,args[1])!=-1')
|
||||
elseif len(args) == 3
|
||||
return map(filter(testgroups, 'v:val.type==args[1]')[0].categories, 'substitute(v:val.name," ","_","g")')
|
||||
endif
|
||||
catch
|
||||
endtry
|
||||
return []
|
||||
endfunction
|
||||
|
||||
command! -nargs=* -complete=customlist,g:zencoding_unittest_complete ZenCodingUnitTest call s:do_tests(<f-args>)
|
||||
if s:sfile == expand('%:p')
|
||||
ZenCodingUnitTest
|
||||
endif
|
||||
|
||||
finish
|
||||
[
|
||||
{
|
||||
'type': "html",
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "div",
|
||||
'result': "<div></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper",
|
||||
'result': "<div id=\"wrapper\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div.box",
|
||||
'result': "<div class=\"box\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[title=TITLE]",
|
||||
'result': "<a href=\"\" title=\"TITLE\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper.box",
|
||||
'result': "<div id=\"wrapper\" class=\"box\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper.box.current",
|
||||
'result': "<div id=\"wrapper\" class=\"box current\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#wrapper.box.current[title=TITLE rel]",
|
||||
'result': "<div id=\"wrapper\" rel=\"\" class=\"box current\" title=\"TITLE\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#main+div#sub",
|
||||
'result': "<div id=\"main\"></div>\n<div id=\"sub\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#main>div#sub",
|
||||
'result': "<div id=\"main\">\n\t<div id=\"sub\"></div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "html:xt>div#header>div#logo+ul#nav>li.item-$*5>a",
|
||||
'result': "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\" />\n\t<title></title>\n</head>\n<body>\n\t<div id=\"header\">\n\t\t<div id=\"logo\"></div>\n\t\t<ul id=\"nav\">\n\t\t\t<li class=\"item-1\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-2\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-3\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-4\"><a href=\"\"></a></li>\n\t\t\t<li class=\"item-5\"><a href=\"\"></a></li>\n\t\t</ul>\n\t</div>\n\t\n</body>\n</html>",
|
||||
},
|
||||
{
|
||||
'query': "ol>li*2",
|
||||
'result': "<ol>\n\t<li></li>\n\t<li></li>\n</ol>\n",
|
||||
},
|
||||
{
|
||||
'query': "a",
|
||||
'result': "<a href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "obj",
|
||||
'result': "<object data=\"\" type=\"\"></object>\n",
|
||||
},
|
||||
{
|
||||
'query': "cc:ie6>p+blockquote#sample$.so.many.classes*2",
|
||||
'result': "<!--[if lte IE 6]>\n\t<p></p>\n\t<blockquote id=\"sample1\" class=\"so many classes\"></blockquote>\n\t<blockquote id=\"sample2\" class=\"so many classes\"></blockquote>\n\t\n<![endif]-->",
|
||||
},
|
||||
{
|
||||
'query': "html:4t>div#wrapper>div#header+div#contents+div#footer",
|
||||
'result': "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<html lang=\"en\">\n<head>\n\t<meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n\t<title></title>\n</head>\n<body>\n\t<div id=\"wrapper\">\n\t\t<div id=\"header\"></div>\n\t\t<div id=\"contents\"></div>\n\t\t<div id=\"footer\"></div>\n\t</div>\n\t\n</body>\n</html>",
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/].foo#hoge",
|
||||
'result': "<a id=\"hoge\" href=\"http://www.google.com/\" class=\"foo\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=http://www.google.com/]{Google}",
|
||||
'result': "<a href=\"http://www.google.com/\">Google</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "{ZenCoding}",
|
||||
'result': "ZenCoding",
|
||||
},
|
||||
{
|
||||
'query': "a+b",
|
||||
'result': "<a href=\"\"></a>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i<b",
|
||||
'result': "<a href=\"\"><b><i></i></b><b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i^b",
|
||||
'result': "<a href=\"\"><b><i></i></b><b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i<<b",
|
||||
'result': "<a href=\"\"><b><i></i></b></a>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i^^b",
|
||||
'result': "<a href=\"\"><b><i></i></b></a>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i<<b",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "blockquote>b>i^^b",
|
||||
'result': "<blockquote><b><i></i></b></blockquote>\n<b></b>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[href=foo][class=bar]",
|
||||
'result': "<a href=\"foo\" class=\"bar\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]{foo}*2",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\">foo</a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a[a=b][b=c=d][e]*2{foo}",
|
||||
'result': "<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\n<a a=\"b\" b=\"c=d\" e=\"\" href=\"\"></a>\nfoo",
|
||||
},
|
||||
{
|
||||
'query': "a*2{foo}a",
|
||||
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo<a href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a{foo}*2>b",
|
||||
'result': "<a href=\"\">foo<b></b></a>\n<a href=\"\">foo<b></b></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "a*2{foo}>b",
|
||||
'result': "<a href=\"\"></a>\n<a href=\"\"></a>\nfoo",
|
||||
},
|
||||
{
|
||||
'query': "table>tr>td.name#foo+td*3",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td id=\"foo\" class=\"name\"></td>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#header + div#footer",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header + div#footer",
|
||||
'result': "<div id=\"header\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header > ul > li < p{Footer}",
|
||||
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header > ul > li ^ p{Footer}",
|
||||
'result': "<div id=\"header\">\n\t<ul>\n\t\t<li></li>\n\t</ul>\n\t<p>Footer</p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "a#foo$$$*3",
|
||||
'result': "<a id=\"foo001\" href=\"\"></a>\n<a id=\"foo002\" href=\"\"></a>\n<a id=\"foo003\" href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "ul+",
|
||||
'result': "<ul>\n\t<li></li>\n</ul>\n",
|
||||
},
|
||||
{
|
||||
'query': "table+",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header>li<#content",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "#header>li^#content",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(#header>li)<#content",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(#header>li)^#content",
|
||||
'result': "<div id=\"header\">\n\t<li></li>\n</div>\n<div id=\"content\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i<<div",
|
||||
'result': "<a href=\"\"><b><i></i></b></a>\n<div></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "a>b>i^^div",
|
||||
'result': "<a href=\"\"><b><i></i></b></a>\n<div></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(#header>h1)+#content+#footer",
|
||||
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\"></div>\n<div id=\"footer\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(#header>h1)+(#content>(#main>h2+div#entry$.section*5>(h3>a)+div>p*3+ul+)+(#utilities))+(#footer>address)",
|
||||
'result': "<div id=\"header\">\n\t<h1></h1>\n</div>\n<div id=\"content\">\n\t<div id=\"main\">\n\t\t<h2></h2>\n\t\t<div id=\"entry1\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry2\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry3\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry4\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t\t<div id=\"entry5\" class=\"section\">\n\t\t\t<h3><a href=\"\"></a></h3>\n\t\t\t<div>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<p></p>\n\t\t\t\t<ul>\n\t\t\t\t\t<li></li>\n\t\t\t\t</ul>\n\t\t\t</div>\n\t\t</div>\n\t</div>\n\t<div id=\"utilities\"></div>\n</div>\n<div id=\"footer\">\n\t<address></address>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(div>(ul*2)*2)+(#utilities)",
|
||||
'result': "<div>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n\t<ul></ul>\n</div>\n<div id=\"utilities\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "table>(tr>td*3)*4",
|
||||
'result': "<table>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td></td>\n\t\t<td></td>\n\t</tr>\n</table>\n",
|
||||
},
|
||||
{
|
||||
'query': "(((a#foo+a#bar)*2)*3)",
|
||||
'result': "<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n<a id=\"foo\" href=\"\"></a>\n<a id=\"bar\" href=\"\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#box$*3>h3+p*2",
|
||||
'result': "<div id=\"box1\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p></p>\n\t<p></p>\n</div>\n"
|
||||
},
|
||||
{
|
||||
'query': "div#box.foo$$$.bar$$$*3",
|
||||
'result': "<div id=\"box\" class=\"foo001 bar001\"></div>\n<div id=\"box\" class=\"foo002 bar002\"></div>\n<div id=\"box\" class=\"foo003 bar003\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div#box$*3>h3+p.bar*2|e",
|
||||
'result': "<div id=\"box1\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box2\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n<div id=\"box3\">\n\t<h3></h3>\n\t<p class=\"bar\"></p>\n\t<p class=\"bar\"></p>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div>div#page>p.title+p|c",
|
||||
'result': "<div>\n\t<!-- #page -->\n\t<div id=\"page\">\n\t\t<!-- .title -->\n\t\t<p class=\"title\"></p>\n\t\t<!-- /.title -->\n\t\t<p></p>\n\t</div>\n\t<!-- /#page -->\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "link:css",
|
||||
'result': "<link media=\"all\" rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" />\n",
|
||||
},
|
||||
{
|
||||
'query': "a[title=\"Hello', world\" rel]",
|
||||
'result': "<a rel=\"\" href=\"\" title=\"Hello', world\"></a>\n",
|
||||
},
|
||||
{
|
||||
'query': "div>a#foo{bar}",
|
||||
'result': "<div><a id=\"foo\" href=\"\">bar</a></div>\n",
|
||||
},
|
||||
{
|
||||
'query': ".content{Hello!}",
|
||||
'result': "<div class=\"content\">Hello!</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div.logo+(div#navigation)+(div#links)",
|
||||
'result': "<div class=\"logo\"></div>\n<div id=\"navigation\"></div>\n<div id=\"links\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "h1{header}+{Text}+a[href=http://link.org]{linktext}+{again some text}+a[href=http://anoterlink.org]{click me!}+{some final text}",
|
||||
'result': "<h1>header</h1>\nText<a href=\"http://link.org\">linktext</a>\nagain some text<a href=\"http://anoterlink.org\">click me!</a>\nsome final text",
|
||||
},
|
||||
{
|
||||
'query': "a{&}+div{&&}",
|
||||
'result': "<a href=\"\">&</a>\n<div>&&</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "<foo/>span$$$$\\<c-y>,$$$$",
|
||||
'result': "<foo/><span></span>",
|
||||
},
|
||||
{
|
||||
'query': "foo span$$$$\\<c-y>,$$$$",
|
||||
'result': "foo <span></span>",
|
||||
},
|
||||
{
|
||||
'query': "foo span$$$$\\<c-y>,$$$$ bar",
|
||||
'result': "foo <span></span> bar",
|
||||
},
|
||||
{
|
||||
'query': "foo $$$$\\<c-o>ve\\<c-y>,p\\<cr>$$$$bar baz",
|
||||
'result': "foo <p>bar</p> baz",
|
||||
},
|
||||
{
|
||||
'query': "foo $$$$\\<c-o>vee\\<c-y>,p\\<cr>$$$$bar baz",
|
||||
'result': "foo <p>bar baz</p>",
|
||||
},
|
||||
{
|
||||
'query': "f div.boxes>article.box2>header>(hgroup>h2{aaa}+h3{bbb})+p{ccc}$$$$",
|
||||
'result': "f <div class=\"boxes\">\n\t<article class=\"box2\">\n\t\t<header>\n\t\t\t<hgroup>\n\t\t\t\t<h2>aaa</h2>\n\t\t\t\t<h3>bbb</h3>\n\t\t\t</hgroup>\n\t\t\t<p>ccc</p>\n\t\t</header>\n\t</article>\n</div>",
|
||||
},
|
||||
{
|
||||
'query': "div.boxes>(div.box2>section>h2{a}+p{b})+(div.box1>section>h2{c}+p{d}+p{e}+(bq>h2{f}+h3{g})+p{h})",
|
||||
'result': "<div class=\"boxes\">\n\t<div class=\"box2\">\n\t\t<section>\n\t\t\t<h2>a</h2>\n\t\t\t<p>b</p>\n\t\t</section>\n\t</div>\n\t<div class=\"box1\">\n\t\t<section>\n\t\t\t<h2>c</h2>\n\t\t\t<p>d</p>\n\t\t\t<p>e</p>\n\t\t\t<blockquote>\n\t\t\t\t<h2>f</h2>\n\t\t\t\t<h3>g</h3>\n\t\t\t</blockquote>\n\t\t\t<p>h</p>\n\t\t</section>\n\t</div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "(div>(label+input))+div",
|
||||
'result': "<div>\n\t<label for=\"\"></label>\n\t<input type=\"\" />\n</div>\n<div></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,ul>li>span*>a\\<cr>$$$$",
|
||||
'result': "<ul>\n\t<li>\n\t\t<span><a href=\"\">test1</a></span>\n\t\t<span><a href=\"\">test2</a></span>\n\t\t<span><a href=\"\">test3</a></span>\n\t</li>\n</ul>",
|
||||
},
|
||||
{
|
||||
'query': "test1\ntest2\ntest3$$$$\\<esc>ggVG\\<c-y>,input[type=input value=$#]*\\<cr>$$$$",
|
||||
'result': "<input type=\"input\" value=\"test1\" />\n<input type=\"input\" value=\"test2\" />\n<input type=\"input\" value=\"test3\" />",
|
||||
},
|
||||
{
|
||||
'query': "div#id-$*5>div#id2-$",
|
||||
'result': "<div id=\"id-1\">\n\t<div id=\"id2-1\"></div>\n</div>\n<div id=\"id-2\">\n\t<div id=\"id2-2\"></div>\n</div>\n<div id=\"id-3\">\n\t<div id=\"id2-3\"></div>\n</div>\n<div id=\"id-4\">\n\t<div id=\"id2-4\"></div>\n</div>\n<div id=\"id-5\">\n\t<div id=\"id2-5\"></div>\n</div>\n",
|
||||
},
|
||||
{
|
||||
'query': "{test case $ }*3",
|
||||
'result': "test case 1 test case 2 test case 3 ",
|
||||
},
|
||||
{
|
||||
'query': "{test case $${nr}}*3",
|
||||
'result': "test case 1\ntest case 2\ntest case 3\n",
|
||||
},
|
||||
{
|
||||
'query': "{test case \\$ }*3",
|
||||
'result': "test case $ test case $ test case $ ",
|
||||
},
|
||||
{
|
||||
'query': "{test case $$$ }*3",
|
||||
'result': "test case 001 test case 002 test case 003 ",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'split join tag',
|
||||
'tests': [
|
||||
{
|
||||
'query': "<div>\n\t<span>$$$$\\<c-y>j$$$$</span>\n</div>",
|
||||
'result': "<div>\n\t<span/>\n</div>",
|
||||
},
|
||||
{
|
||||
'query': "<div>\n\t<span$$$$\\<c-y>j$$$$/>\n</div>",
|
||||
'result': "<div>\n\t<span></span>\n</div>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'toggle comment',
|
||||
'tests': [
|
||||
{
|
||||
'query': "<div>\n\t<span>$$$$\\<c-y>/$$$$</span>\n</div>",
|
||||
'result': "<div>\n\t<!-- <span></span> -->\n</div>",
|
||||
},
|
||||
{
|
||||
'query': "<div>\n\t<!-- <span>$$$$\\<c-y>/$$$$</span> -->\n</div>",
|
||||
'result': "<div>\n\t<span></span>\n</div>",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'image size',
|
||||
'tests': [
|
||||
{
|
||||
'query': "img[src=http://mattn.kaoriya.net/images/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"http://mattn.kaoriya.net/images/logo.png\" alt=\"\" width=\"96\" height=\"96\" />",
|
||||
},
|
||||
{
|
||||
'query': "img[src=/logo.png]$$$$\\<c-y>,\\<c-y>i$$$$",
|
||||
'result': "<img src=\"/logo.png\" alt=\"\" />",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'move next prev',
|
||||
'tests': [
|
||||
{
|
||||
'query': "foo+bar+baz[dankogai=\"\"]$$$$\\<c-y>,\\<esc>gg0\\<c-y>n\\<c-y>n\\<c-y>n\\<esc>Byw:%d _\\<cr>p$$$$",
|
||||
'result': "dankogai",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'css',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "@i",
|
||||
'result': "@import url();",
|
||||
},
|
||||
{
|
||||
'query': "fs:n",
|
||||
'result': "font-style: normal;",
|
||||
},
|
||||
{
|
||||
'query': "fl:l|fc",
|
||||
'result': "float: left;",
|
||||
},
|
||||
{
|
||||
'query': "bg+$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat;",
|
||||
},
|
||||
{
|
||||
'query': "bg+!$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat !important;",
|
||||
},
|
||||
{
|
||||
'query': "m$$$$",
|
||||
'result': "margin: $$$$;",
|
||||
},
|
||||
{
|
||||
'query': "m0.1p$$$$",
|
||||
'result': "margin: 0.1%;",
|
||||
},
|
||||
{
|
||||
'query': "m1.0$$$$",
|
||||
'result': "margin: 1.0em;",
|
||||
},
|
||||
{
|
||||
'query': "m2$$$$",
|
||||
'result': "margin: 2px;",
|
||||
},
|
||||
{
|
||||
'query': "bdrs10$$$$",
|
||||
'result': "border-radius: 10px;",
|
||||
},
|
||||
{
|
||||
'query': "-bdrs20$$$$",
|
||||
'result': "-webkit-border-radius: 20px;\n-moz-border-radius: 20px;\nborder-radius: 20px;",
|
||||
},
|
||||
{
|
||||
'query': "lg(top,#fff,#000)$$$$",
|
||||
'result': "background-image: -webkit-gradient(top, 0 0, 0 100, from(#fff), to(#000));\nbackground-image: -webkit-linear-gradient(#fff, #000);\nbackground-image: -moz-linear-gradient(#fff, #000);\nbackground-image: -o-linear-gradient(#fff, #000);\nbackground-image: linear-gradient(#fff, #000);\n",
|
||||
},
|
||||
{
|
||||
'query': "m10-5-0$$$$",
|
||||
'result': "margin: 10px 5px 0px;",
|
||||
},
|
||||
{
|
||||
'query': "m-10--5$$$$",
|
||||
'result': "margin: -10px -5px;",
|
||||
},
|
||||
{
|
||||
'query': "m10-auto$$$$",
|
||||
'result': "margin: 10px auto;",
|
||||
},
|
||||
{
|
||||
'query': "w100p$$$$",
|
||||
'result': "width: 100%;",
|
||||
},
|
||||
{
|
||||
'query': "h50e$$$$",
|
||||
'result': "height: 50em;",
|
||||
},
|
||||
{
|
||||
'query': "(bg+)+c$$$$",
|
||||
'result': "background: #FFF url($$$$) 0 0 no-repeat;\ncolor: #000;",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'haml',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
|
||||
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
|
||||
},
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|haml",
|
||||
'result': "%div\n %p\n %ul#foo\n %li.bar1{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar2{ :foo => \"bar\", :bar => \"baz\" } baz\n %li.bar3{ :foo => \"bar\", :bar => \"baz\" } baz\n",
|
||||
},
|
||||
{
|
||||
'query': "a*3|haml",
|
||||
'result': "%a{ :href => \"\" }\n%a{ :href => \"\" }\n%a{ :href => \"\" }\n",
|
||||
},
|
||||
{
|
||||
'query': ".content{Hello!}|haml",
|
||||
'result': "%div.content Hello!\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "%a foo\n bar$$$$\\<c-y>j$$$$",
|
||||
'result': "%a ",
|
||||
},
|
||||
{
|
||||
'query': "$$$$\\<c-y>j$$$$%a ",
|
||||
'result': "%a $$$$",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'toggle comment',
|
||||
'tests': [
|
||||
{
|
||||
'query': "%a{ :href => \"http://www.google.com\"$$$$\\<c-y>/$$$$ } hello",
|
||||
'result': "-# %a{ :href => \"http://www.google.com\" } hello",
|
||||
},
|
||||
{
|
||||
'query': "-# %a{ :href => \"http://www.google.com\"$$$$\\<c-y>/$$$$ } hello",
|
||||
'result': "%a{ :href => \"http://www.google.com\" } hello",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'slim',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n",
|
||||
},
|
||||
{
|
||||
'query': "div>p+ul#foo>li.bar$[foo=bar][bar=baz]*3>{baz}|slim",
|
||||
'result': "div\n p\n ul id=\"foo\"\n li foo=\"bar\" bar=\"baz\" class=\"bar1\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar2\"\n | baz\n li foo=\"bar\" bar=\"baz\" class=\"bar3\"\n | baz\n",
|
||||
},
|
||||
{
|
||||
'query': "a*3|slim",
|
||||
'result': "a href=\"\"\na href=\"\"\na href=\"\"\n",
|
||||
},
|
||||
{
|
||||
'query': ".content{Hello!}|slim",
|
||||
'result': "div class=\"content\"\n | Hello!\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'split join tag',
|
||||
'tests': [
|
||||
{
|
||||
'query': "a\n | foo$$$$\\<c-y>j$$$$",
|
||||
'result': "a",
|
||||
},
|
||||
{
|
||||
'query': "a$$$$\\<c-y>j$$$$",
|
||||
'result': "a\n | $$$$",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'name': 'toggle comment',
|
||||
'tests': [
|
||||
{
|
||||
'query': "a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello",
|
||||
'result': "/a href=\"http://www.google.com\"\n | hello",
|
||||
},
|
||||
{
|
||||
'query': "/a href=\"http://www.google.com\"$$$$\\<c-y>/$$$$\n | hello",
|
||||
'result': "a href=\"http://www.google.com\"\n | hello",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'xsl',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "vari",
|
||||
'result': "<xsl:variable name=\"\"></xsl:variable>\n",
|
||||
},
|
||||
{
|
||||
'query': "ap>wp",
|
||||
'result': "<xsl:apply-templates select=\"\" mode=\"\">\n\t<xsl:with-param select=\"\" name=\"\"></xsl:with-param>\n</xsl:apply-templates>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'xsd',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "xsd:w3c",
|
||||
'result': "<?xml version=\"1.0\"?>\n<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n\t<xsd:element name=\"\" type=\"\"/>\n</xsd:schema>",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'type': 'mustache',
|
||||
'categories': [
|
||||
{
|
||||
'name': 'expand abbreviation',
|
||||
'tests': [
|
||||
{
|
||||
'query': "div#{{foo}}",
|
||||
'result': "<div id=\"{{foo}}\"></div>\n",
|
||||
},
|
||||
{
|
||||
'query': "div.{{foo}}",
|
||||
'result': "<div class=\"{{foo}}\"></div>\n",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
" vim:set et:
|
||||
265
zencoding.vim.vimup
Normal file
265
zencoding.vim.vimup
Normal file
@@ -0,0 +1,265 @@
|
||||
script_name: ZenCoding.vim
|
||||
script_id: '2981'
|
||||
script_type: utility
|
||||
script_package: zencoding-vim.zip
|
||||
script_version: '0.80'
|
||||
required_vim_version: '7.0'
|
||||
summary: vim plugins for HTML and CSS hi-speed coding.
|
||||
|
||||
detailed_description: |
|
||||
|
||||
This is vim script support expanding abbreviation like zen-coding.
|
||||
ref: http://code.google.com/p/zen-coding/
|
||||
|
||||
There is a movie using zencoding.vim
|
||||
ref: http://mattn.github.com/zencoding-vim
|
||||
|
||||
Source Repository.
|
||||
ref: http://github.com/mattn/zencoding-vim
|
||||
|
||||
Type abbreviation
|
||||
+-------------------------------------
|
||||
| html:5_
|
||||
+-------------------------------------
|
||||
"_" is a cursor position. and type "<c-y>," (Ctrl + y and Comma)
|
||||
NOTE: Don't worry about key map. you can change it easily.
|
||||
+-------------------------------------
|
||||
| <!DOCTYPE HTML>
|
||||
| <html lang="en">
|
||||
| <head>
|
||||
| <title></title>
|
||||
| <meta charset="UTF-8">
|
||||
| </head>
|
||||
| <body>
|
||||
| _
|
||||
| </body>
|
||||
| </html>
|
||||
+-------------------------------------
|
||||
Type following
|
||||
+-------------------------------------
|
||||
| div#foo$*2>div.bar
|
||||
+-------------------------------------
|
||||
And type "<c-y>,"
|
||||
+-------------------------------------
|
||||
|<div id="foo1">
|
||||
| <div class="bar">_</div>
|
||||
|</div>
|
||||
|<div id="foo2">
|
||||
| <div class="bar"></div>
|
||||
|</div>
|
||||
| _
|
||||
+-------------------------------------
|
||||
|
||||
Tutorial:
|
||||
|
||||
http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
|
||||
|
||||
How work this:
|
||||
|
||||
http://mattn.github.com/zencoding-vim
|
||||
|
||||
Tips:
|
||||
|
||||
You can customize behavior of expanding with overriding config.
|
||||
This configuration will be marged at loading plugin.
|
||||
|
||||
let g:user_zen_settings = {
|
||||
\ 'indentation' : ' ',
|
||||
\ 'perl' : {
|
||||
\ 'aliases' : {
|
||||
\ 'req' : 'require '
|
||||
\ },
|
||||
\ 'snippets' : {
|
||||
\ 'use' : "use strict\nuse warnings\n\n",
|
||||
\ 'warn' : "warn \"|\";",
|
||||
\ }
|
||||
\ }
|
||||
\}
|
||||
|
||||
let g:user_zen_expandabbr_key = '<c-e>'
|
||||
|
||||
let g:use_zen_complete_tag = 1
|
||||
|
||||
You can set language attribute in html using zen_settings['lang'].
|
||||
|
||||
install_details: |
|
||||
|
||||
# cd ~/.vim
|
||||
# unzip zencoding-vim.zip
|
||||
|
||||
or if you install pathogen.vim:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# unzip /path/to/zencoding-vim.zip
|
||||
|
||||
if you get sources from repository:
|
||||
|
||||
# cd ~/.vim/bundle # or make directory
|
||||
# git clone http://github.com/mattn/zencoding-vim.git
|
||||
|
||||
versions:
|
||||
- '0.80': |
|
||||
This is an upgrade for ZenCoding.vim: add emmet features.
|
||||
- '0.74': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes.
|
||||
- '0.73': |
|
||||
This is an upgrade for ZenCoding.vim: many bug fixes. and support slim format (experimental).
|
||||
- '0.72': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding tokens.
|
||||
- '0.71': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fix finding begin of tokens.
|
||||
- '0.70': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[mod] Changed behavior of expanding. "div div>a|" should keep first div element.
|
||||
[add] Supported slim formatter.
|
||||
- '0.60': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expanding {{}}.
|
||||
- '0.59': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed toggleComment and mny bugs.
|
||||
- '0.58': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed 'foo+' style expandos.
|
||||
- '0.57': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed expandos that don't work 'choose' in xsl.
|
||||
- '0.56': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed contents parser.
|
||||
- '0.55': |
|
||||
uploaded again: sorry, files was old.
|
||||
- '0.54': |
|
||||
[add] support sass, xsd.
|
||||
[fix] expanding with html tag.
|
||||
uploaded again: sorry, fileformat was DOS.
|
||||
- '0.53': |
|
||||
[fix] gif width/height was swapped.
|
||||
- '0.52': |
|
||||
[fix] broken wrap expanding.
|
||||
- '0.51': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] wrap expanding with '&'.
|
||||
[fix] expand .content to class="content".
|
||||
[fix] haml expanding.
|
||||
[fix] bg+ snippet
|
||||
- '0.50': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] fixed parsing '#{{foo}}' and '.{{bar}}'.
|
||||
- '0.49': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[doc] add help manual.
|
||||
- '0.48': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[fix] install mappings to global.
|
||||
- '0.47': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
package was empty. upload again.
|
||||
- '0.46': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
[drastic changes] enable autoload. you should whole replace older files.
|
||||
- '0.45': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed attribute parsing like: a[href="hello', world" rel].
|
||||
- '0.44': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed checking whether have mapping using maparg() / hasmapto().
|
||||
- '0.43': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed behavior for nested block. like "html:5>#page>(header#globalHeader>(hgroup>h1+h2)+(nav>ul>li*3>a)+(form>p.siteSearch>input+input[type=button]))+(#contents>(#main>(section>h2+p*5)+p.pagetop>a[href=#page])+(#sub>p+(nav>ul>li>a)))+(footer#globalFoooter>(ul>li>a)+(p.copyright>small))"
|
||||
- '0.42': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed select/option indent.
|
||||
- '0.41': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
fixed default filter. when using 'e' filter, output become empty.
|
||||
- '0.40': |
|
||||
This is an upgrade for ZenCoding.vim:
|
||||
add the pure vimscript code for 'get image size'. you can use it without perl interface just now.
|
||||
change key assign of ZenCodingExpandWord from ',' to ';'. it don't effect to most users.
|
||||
- '0.39': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem about 'selection'. see http://github.com/mattn/zencoding-vim/issues/#issue/2
|
||||
- '0.38': |
|
||||
This is an upgrade for ZenCoding.vim: use v7h"_s instead of v7hs for backspace.
|
||||
- '0.37': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that won't working with some 'backspace' options.
|
||||
- '0.36': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that filter does not work.
|
||||
- '0.35': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for other languages. (meaning php also)
|
||||
- '0.34': |
|
||||
This is an upgrade for ZenCoding.vim: enable zencoding for xsl. (you should add ~/.vim/ftplugin/xslt/zencoding.vim)
|
||||
- '0.33': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem breaking multibyte when cursor is in a part of line. enabled zencoding for javascript in html.
|
||||
- '0.32': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation. supported extends so that you can enable zencoding for php/xhtml/haml other's section 14 in http://github.com/mattn/zencoding-vim/raw/master/TUTORIAL
|
||||
- '0.31': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indentation and $$$ problem. fixed about missing support multiple classes.
|
||||
- '0.30': |
|
||||
This is an upgrade for ZenCoding.vim: Fixed key assign.
|
||||
- '0.29': |
|
||||
This is an upgrade for ZenCoding.vim: Changed leading key to '<c-y>' from '<c-z>'.
|
||||
- '0.28': |
|
||||
This is an upgrade for ZenCoding.vim: supported 'Balance Tag Inward/Outward', 'Go to Next/Previous Edit Point', 'Update <img> Size', 'Remove Tag', 'Split/Join Tag', 'Toggle Comment'
|
||||
- '0.27': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that can't work on the part of multibyte characters. fixed inline elements behavior.
|
||||
- '0.26': |
|
||||
This is an upgrade for ZenCoding.vim: The count of '(((a#foo + a#bar)*2)*3)' should be 12.
|
||||
- '0.25': |
|
||||
This is an upgrade for ZenCoding.vim: store undo before working. good luck about 'table>(tr>td*3)*4'.
|
||||
- '0.24': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of parsing area of visual selection.
|
||||
- '0.23': |
|
||||
This is an upgrade for ZenCoding.vim: pre-expand '#header>li<#content' to 'div#header>li<div#content'. support () expression.
|
||||
- '0.22': |
|
||||
This is an upgrade for ZenCoding.vim: expand 'ul+' to 'ul>li'. fix undo ring. support visual selection. when type trigger key on visual select, it request you leader like 'ul>li'. if you give 'ul>li*' as leader, you'll get each separate 'ul>li' tags. and when you give 'blockquote' as leader, you'll get blocked text.
|
||||
- '0.21': |
|
||||
This is an upgrade for ZenCoding.vim: treat xhtml as html.
|
||||
- '0.20': |
|
||||
This is an upgrade for ZenCoding.vim: add option use_zen_complete_tag for complete abbr.
|
||||
- '0.19': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that couldn't expand 'link:css' correctly.
|
||||
- '0.18': |
|
||||
This is an upgrade for ZenCoding.vim: ignore duplicate key map.
|
||||
- '0.17': |
|
||||
This is an upgrade for ZenCoding.vim: fixed key map.
|
||||
- '0.16': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem 'endless loop'.
|
||||
- '0.15': |
|
||||
This is an upgrade for ZenCoding.vim: set default filetype to 'html'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: fixed tag name like 'fs:n' in 'css'.
|
||||
- '0.14': |
|
||||
This is an upgrade for ZenCoding.vim: indentation for each languages.
|
||||
- '0.13': |
|
||||
This is an upgrade for ZenCoding.vim: user key map.
|
||||
- '0.12': |
|
||||
This is an upgrade for ZenCoding.vim: few extensive notation.
|
||||
- '0.11': |
|
||||
This is an upgrade for ZenCoding.vim: fixed indent.
|
||||
- '0.10': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior of '+' operator
|
||||
- '0.9': |
|
||||
This is an upgrade for ZenCoding.vim: fixed single line behavior
|
||||
- '0.8': |
|
||||
This is an upgrade for ZenCoding.vim: support 'a[href=http://www.google.com]{Google}'
|
||||
- '0.7': |
|
||||
This is an upgrade for ZenCoding.vim: fixed behavior in 'a+b'.
|
||||
- '0.6': |
|
||||
This is an upgrade for ZenCoding.vim: fixed strange behavior about '<a href="">b_</a>'.
|
||||
- '0.5': |
|
||||
This is an upgrade for ZenCoding.vim: recover rest part in line.
|
||||
- '0.4': |
|
||||
This is an upgrade for ZenCoding.vim: fixed cursor position. fixed ${lang} replacement.
|
||||
- '0.3': |
|
||||
This is an upgrade for ZenCoding.vim: fixed line expanding.
|
||||
- '0.2': |
|
||||
This is an upgrade for ZenCoding.vim: fixed problem that moving cursor with expanding.
|
||||
- '0.1': |
|
||||
Initial upload
|
||||
|
||||
# __END__
|
||||
# vim: filetype=yaml
|
||||
Reference in New Issue
Block a user