Open eight04 opened 2 years ago
The vato\e
trick doesn't work on broken tags e,g, <input>
without a closing tag.
Now I use this:
nnoremap <C-y>u :call EmmetUpdateTag()<CR>
function! EmmetUpdateTag()
let old_pos = getpos(".")
let old_search = @/
let @/ = '\v\<\w[^>]+\>'
execute "normal! gN\e"
let pos2 = getpos("'>")
if CmpList(old_pos, pos2) > 0
call setpos(".", old_pos)
execute "normal! vato\e"
endif
execute "normal \<plug>(emmet-update-tag)"
let @/ = old_search
endfunction
function CmpList(a, b)
let i = 0
let length = len(a:a)
while i < length
if a:a[i] > a:b[i]
return 1
elseif a:a[i] < a:b[i]
return -1
endif
let i += 1
endwhile
return 0
endfunction
With the following content:
<C-Y>u
only works when the cursor is on the first line:It does nothing from the
>
character:When the cursor is on the closing tag, the closing tag will be deleted:
Currently I use a mapping to make it work like regular emmet: