diff --git a/TUTORIAL b/TUTORIAL index b049740..485c371 100644 --- a/TUTORIAL +++ b/TUTORIAL @@ -99,7 +99,21 @@ Tutorial of zencoding.vim 10. Split/Join Tag - under construction + Move cursor to block + --------------------- +
+ cursor is here +
+ --------------------- + Type 'j' in insert mode. + --------------------- +
+ --------------------- + And type 'j' in there. + --------------------- +
+
+ --------------------- 11. Toggle Comment diff --git a/zencoding.vim b/zencoding.vim index 75df2e8..75c98c1 100644 --- a/zencoding.vim +++ b/zencoding.vim @@ -87,6 +87,8 @@ for item in [ \ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '/', 'plug': 'ZenCodingToggleComment', 'func': ':call zen_toggleComment()'}, \ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTag', 'func': ':call zen_splitJoinTag()a'}, \ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': 'j', 'plug': 'ZenCodingSplitJoinTag', 'func': ':call zen_splitJoinTag()'}, +\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zen_removeTag()a'}, +\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': 'k', 'plug': 'ZenCodingRemoveTag', 'func': ':call zen_removeTag()'}, \] if !hasmapto(''.item.plug, item.mode) @@ -1316,6 +1318,28 @@ function! s:zen_splitJoinTag() endif endfunction +function! s:zen_removeTag() + let mx1 = '<[a-zA-Z][a-zA-Z0-9]*[^/>\s]*>' + let mx2 = '<\/[^>]\+>' + let block = s:search_region(mx1, mx2) + if s:cursor_in_region(block) + let content = s:get_content(block) + let tag_name = substitute(content, '^<\([a-zA-Z0-9]*\).*$', '\1', '') + echo matchstr(content, mx2) + echo tag_name + if matchstr(content, mx2) =~ '\s]*' + let mx2 = '[^/>\s]*/>' + let empty = s:search_region(mx1, mx2) + if s:cursor_in_region(empty) + call s:change_content(empty, '') + endif + endif +endfunction + function! ZenExpand(abbr, type, orig) let items = s:zen_parseIntoTree(a:abbr, a:type).child let expand = ''