*emmet.txt* Emmet for Vim ------------------------------------------------------- Emmet: vim plugins for HTML and CSS hi-speed coding ------------------------------------------------------- Author: Yasuhiro Matsumoto WebSite: http://mattn.kaoriya.net/ Repository: http://github.com/mattn/emmet-vim Site: http://mattn.github.com/emmet-vim License: BSD style license ============================================================================== CONTENTS *emmet-contents* Introduction |emmet-introduction| Install |emmet-install| Tutorial |emmet-tutorial| 1. Expand Abbreviation |emmet-expandabbr| 2. Wrap with Abbreviation |emmet-wrap-with-abbreviation| 3. Balance Tag Inward |emmet-balance-tag-inward| 4. Balance Tag Outward |emmet-balance-tag-outward| 5. Go to Next Edit Point |emmet-goto-next-point| |n| 6. Go to Previous Edit Point |emmet-goto-previous-point| 7. Update Size |emmet-update-image-size| 8. Merge Lines |emmet-merge-lines| 9. Remove Tag |emmet-remove-tag| 10. Split/Join Tag |emmet-split-join-tag| 11. Toggle Comment |emmet-toggle-comment| 12. Make anchor from URL |emmet-make-anchor-url| 13. Make quoted text from URL |emmet-quoted-text-url| 14. Code Pretty |emmet-code-pretty| 15. Lorem Ipsum |emmet-lorem-ipsum| Customize |emmet-customize| 1. Key Mappings |emmet-customize-keymappings| 2. Indent Size |emmet-indent-size| 3. Define Tag's Behavior |emmet-define-tags-behavior| 4. Complete Tag |emmet-complete-tag| Links |emmet-links| ToDo |emmet-todo| ============================================================================== INTRODUCTION *emmet-introduction* *emmet* |Emmet| 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: >
< Read more about current Emmet syntax http://docs.emmet.io/abbreviations/ Abbreviation engine has a modular structure which allows you to expand abbreviations into different languages. Emmet currently supports CSS, HTML, XML/XSL and HAML, Slim languages via filters. ============================================================================== INSTALL *emmet-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 *emmet-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 'emmet-tutor.txt'. Formally, open the file to start tutorial. 1. Expand Abbreviation *emmet-expandabbr* *,* Type abbreviation as 'div>p#foo$*3>a' and type |,|. >

< 2. Wrap with Abbreviation *emmet-wrap-with-abbreviation* *v_,* Write as below. > test1 test2 test3 < Then do visual select(line wise) and type |,|. If you request 'Tag:', then type 'ul>li*'. >
  • test1
  • test2
  • test3
< If you type tag as 'blockquote', then you'll see as following. >
test1 test2 test3
< 3. Balance Tag Inward *emmet-balance-tag-inward* *d* To select inward of ul tag, type |d| in insert mode. >
    *
< If cursor is at '*', |d| select from begin of
    to end of
. If cursor is at first of
  • , it select
  • . 4. Balance Tag Outward *emmet-balance-tag-outward* *D* To select outward of ul tag, insert mode, type D in insert mode. >
      *
    < If cursor is at '*', |D| select from next letter of
      to previous letter of
    . If cursor is at first of
  • , it select
  • . 5. Go to Next Edit Point *emmet-goto-next-point* *n* To jump next point that need to edit, type |n| in insert mode. > *
    foo
    < If cursor is at '*', |n| move a cursor into attribute value of div specified id as 'foo'. And type again |n| move a cursor into inner of div specified id as 'bar'. 6. Go to Previous Edit Point *emmet-goto-previous-point* *N* To jump previous point that need to edit, type |N| in insert mode. >
    foo
    * < If cursor is at '*', |N| move a cursor into div specified id as 'bar'. And type again |N| move a cursor into attribute value of 'foo'. 7. Update Size *emmet-update-image-size* *i* To expand or update size of image, type |i| on img tag > < Type 'i' on img tag > < If you change image, then type it again. it will be following. > < 8. Merge Lines *emmet-merge-lines* To join multi line text like following, type |J|. >
    < If you select part of line include
  • and type |m|, it will be following. >
    < 9. Remove Tag *emmet-remove-tag* *k* To remove tag in the block, type |k|. > < Type |k| in insert mode, then >
    < And type |k| in there again, then div will be removed. 10. Split/Join Tag *emmet-split-join-tag* *j* To join block, type |j|. >
    cursor is here
    < Type |j| in insert mode. Then, >
    < And type |j| in there again. >
    < 11. Toggle Comment *emmet-toggle-comment* */* Move cursor to block >
    hello world
    < Type '/' in insert mode. > < Type '/' in there again. >
    hello world
    < 12. Make anchor from URL *emmet-make-anchor-url* *a* Move cursor to URL > http://www.google.com/ < Type |a| > Google < 13. Make quoted text from URL *emmet-quoted-text-url* *A* Move cursor to URL > http://github.com/ < Type |A| >
    Secure source code hosting and collaborative development - GitHub

    How does it work? Get up and running in seconds by forking a project, pushing an existing repository...

    http://github.com/
    < 14. Code Pretty *emmet-code-pretty* *c* Select code block, for example select following code from "int main()". >

    Writing in C language

    int main() { puts("hello world"); } < Type |c| > int main() {
      puts("hello world");
    }
    < 15. Lorem Ipsum *emmet-lorem-ipsum* To insert dummy text. > lorem < Type |,| >
    Adipisicing asperiores deleniti ipsum fuga deserunt perferendis molestiae sunt excepturi aut quo nihil! Optio accusantium corporis molestiae deserunt ab, veritatis commodi. Eius nobis ab deserunt magni iure quo laboriosam laboriosam.
    < For japanese user, put like follow into your g:user_emmet_settings: > let g:user_emmet_settings = { ... \ 'custom_expands1' : { \ '^\%(lorem\|lipsum\)\(\d*\)$' : function('emmet#lorem#ja#expand'), \ }, ... < You will get japanese dummy text. > ============================================================================== CUSTOMIZE *emmet-customize* 1. Key Mapping *emmet-customize-keymappings* To specify leading key for expanding or balance tag, or for all, Add this line in your vimrc: > > let g:user_emmet_leader_key = '' < Note that a trailing ',' must be entered, so the resultant keymap is ','. If you prefer to map for each actions, then you set each variables. 'user_emmet_expandabbr_key' 'user_emmet_expandword_key' 'user_emmet_balancetaginward_key' 'user_emmet_balancetagoutward_key' 'user_emmet_next_key' 'user_emmet_prev_key' 'user_emmet_imagesize_key' 'user_emmet_togglecomment_key' 'user_emmet_splitjointag_key' 'user_emmet_removetag_key' 'user_emmet_anchorizeurl_key' 'user_emmet_anchorizesummary_key' Or if you want to use mappings emmet-expand-abbr emmet-expand-word emmet-balance-tag-inward emmet-balance-tag-outward emmet-move-next emmet-move-prev emmet-image-size emmet-toggle-comment emmet-split-join-tag emmet-remove-tag emmet-anchorize-url emmet-anchorize-summary emmet-merge-lines emmet-code-pretty So you can make the mapping affected only for a filetype you want. > autocmd FileType css imap (emmet-expand-abbr) < 2. Indent Size *emmet-indent-size* To change indent size of html, add this code in your vimrc. > let g:user_emmet_settings = { \ 'html' : { \ 'indentation' : ' ' \ }, \} < If you prefer to change global indent size then add this. > let g:user_emmet_settings = { \ 'indentation' : ' ' \} < 3. Define Tag's Behavior *emmet-define-tags-behavior* Emmet.vim can change behavior of expanding abbreviation for each filetypes as |Dictionary|. For details, see official site of Emmet. for example, vimmer can add following. > let g:user_emmet_settings = { \ 'variables' : { \ '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 *emmet-complete-tag* If you want to complete tags using |omnifunc| then add this. > let g:use_emmet_complete_tag = 1 < 5. Enable functions in different mode If you want to use Emmet only in some modes, set an mode option: let g:user_emmet_mode='n' "only enable normal mode functions, or let g:user_emmet_mode='inv' "enable all functions, which is equal to let g:user_emmet_mode='a' "enable all function in all mode. 6. Adding custom snippets If you have installed the |webapi|(https://github.com/mattn/webapi-vim) for |emmet| you can also add your own snippets using a custom "snippets.json" file. Once you have installed the |webapi| add this line to your 'vimrc': > let g:user_emmet_settings = webapi#json#decode( \ join(readfile(expand('~/.snippets_custom.json')), "\n")) < You can change the path to your snippets_custom.json according to your preferences. See http://docs.emmet.io/customization/snippets/ You can find instructions about creating your customized snippets.json file. ============================================================================== LINKS *emmet-links* Emmet official site: http://emmet.io/ zen-coding official site: http://code.google.com/p/zen-coding/ 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 translated in Chinese: http://www.zfanw.com/blog/zencoding-vim-tutorial-chinese.html ============================================================================== TODO *emmet-todo* * wrapping inline selected. * more documents. * more contributor. * more time to improve emmet.vim. ============================================================================== vim:tw=78:ts=8:ft=help:norl:noet:fen:fdl=0: