-
-
Save kosei27/734448 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! g:endtagcomment() | |
| let tmp = @@ | |
| let tmp_pos = getpos('.') | |
| silent normal vat"yy | |
| let html = @@ | |
| let start_tag = matchstr(html, '\v(\<.{-}\>)') | |
| let tag_name = matchstr(start_tag, '\v([a-zA-Z]+)') | |
| let id_m = matchlist(start_tag, '\vid\=["'']([^"'']+)["'']') | |
| let id = '' | |
| if exists('id_m[1]') | |
| let id = '#' . id_m[1] | |
| endif | |
| let class_m = matchlist(start_tag, '\vclass\=["'']([^"'']+)["'']') | |
| let class = '' | |
| if exists('class_m[1]') | |
| let class = '.' . join(split(class_m[1], '\v\s+'), '.') | |
| endif | |
| call setpos('.', tmp_pos) | |
| let @y = printf('<!-- /%s%s%s -->', tag_name, id, class) | |
| normal "yP | |
| let @@ = tmp | |
| endfunction | |
| nnoremap ,t :<C-u>call g:endtagcomment()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment