forked from VimPlug/emmet-vim
remove tag.
This commit is contained in:
16
TUTORIAL
16
TUTORIAL
@@ -99,7 +99,21 @@ Tutorial of zencoding.vim
|
||||
|
||||
10. Split/Join Tag
|
||||
|
||||
under construction
|
||||
Move cursor to block
|
||||
---------------------
|
||||
<div class="foo">
|
||||
cursor is here
|
||||
</div>
|
||||
---------------------
|
||||
Type '<c-z>j' in insert mode.
|
||||
---------------------
|
||||
<div class="foo"/>
|
||||
---------------------
|
||||
And type '<c-z>j' in there.
|
||||
---------------------
|
||||
<div class="foo">
|
||||
</div>
|
||||
---------------------
|
||||
|
||||
11. Toggle Comment
|
||||
|
||||
|
||||
@@ -87,6 +87,8 @@ for item in [
|
||||
\ {'mode': 'n', 'var': 'user_zen_togglecomment_key', 'key': '<c-z>/', 'plug': 'ZenCodingToggleComment', 'func': ':call <sid>zen_toggleComment()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_splitjointag_key', 'key': '<c-z>j', 'plug': 'ZenCodingSplitJoinTag', 'func': '<esc>:call <sid>zen_splitJoinTag()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_splitjointag_key', 'key': '<c-z>j', 'plug': 'ZenCodingSplitJoinTag', 'func': ':call <sid>zen_splitJoinTag()<cr>'},
|
||||
\ {'mode': 'i', 'var': 'user_zen_removetag_key', 'key': '<c-z>k', 'plug': 'ZenCodingRemoveTag', 'func': '<esc>:call <sid>zen_removeTag()<cr>a'},
|
||||
\ {'mode': 'n', 'var': 'user_zen_removetag_key', 'key': '<c-z>k', 'plug': 'ZenCodingRemoveTag', 'func': ':call <sid>zen_removeTag()<cr>'},
|
||||
\]
|
||||
|
||||
if !hasmapto('<plug>'.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) =~ '</' . tag_name
|
||||
call s:change_content(block, '')
|
||||
endif
|
||||
else
|
||||
let mx1 = '<[a-zA-Z][a-zA-Z0-9]*[^/>\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 = ''
|
||||
|
||||
Reference in New Issue
Block a user