-
-
Save kosei27/734448 to your computer and use it in GitHub Desktop.
Revisions
-
kosei27 revised this gist
Dec 16, 2010 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -85,9 +85,8 @@ endfunction nnoremap ,ti :<C-u>call Endtagcomment('id')<CR> nnoremap ,tc :<C-u>call Endtagcomment('class')<CR> nnoremap ,ta :<C-u>call Endtagcomment('id_class')<CR> nnoremap ,tg :<C-u>call Endtagcomment('tag_id_class')<CR> nmap ,tt :<C-u>normal ,tc<CR> -
kosei27 revised this gist
Dec 9, 2010 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ " endtagcomment.vim " こういうHTMLがあったときに " <div id="hoge" class="fuga"> " ... -
kosei27 revised this gist
Dec 9, 2010 . 1 changed file with 69 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,17 @@ " <div id="hoge" class="fuga"> " ... " <!-- /div#hoge.fuga --></div> " " ---------- " update:2010-12-08 @kosei27 " " ,ti でidのみを出力 " ,tc でclassのみを出力(",tt" ",t" も同様) " ,ta でidとclassを出力 " ,t<Space> でコメント内のテキストの前後の空白をトグル " <!--/hoge--> <-> <!-- /hoge --> function! Endtagcomment(type) let reg_save = @@ try @@ -26,6 +35,10 @@ function! Endtagcomment() let start_tag = matchstr(html, '\v(\<.{-}\>)') let tag_name = matchstr(start_tag, '\v([a-zA-Z]+)') let comment_type = a:type let comment_space = g:endtagcomment_space let firstclass_symbol = g:endtagcomment_firstclass_symbol let id = '' let id_match = matchlist(start_tag, '\vid\=["'']([^"'']+)["'']') if exists('id_match[1]') @@ -35,21 +48,73 @@ function! Endtagcomment() let class = '' let class_match = matchlist(start_tag, '\vclass\=["'']([^"'']+)["'']') if exists('class_match[1]') "let class = '.' . join(split(class_match[1], '\v\s+'), '.') let class = join(split(class_match[1], '\v\s+'), '.') endif execute "normal `>va<\<Esc>`<" if l:comment_type == 'id' let g:endtagcommentFormat = '<!--%comment_space/%id%comment_space-->' elseif l:comment_type == 'class' let g:endtagcommentFormat = '<!--%comment_space/%firstclass_symbol%class%comment_space-->' elseif l:comment_type == 'id_class' let g:endtagcommentFormat = '<!--%comment_space/%id.%class%comment_space-->' elseif l:comment_type == 'tag_id_class' let g:endtagcommentFormat = '<!--%comment_space/%tag_name%id.%class%comment_space-->' endif let comment = g:endtagcommentFormat let comment = substitute(comment, '%comment_space', comment_space, 'g') let comment = substitute(comment, '%firstclass_symbol', firstclass_symbol, 'g') let comment = substitute(comment, '%tag_name', tag_name, 'g') let comment = substitute(comment, '%id', id, 'g') let comment = substitute(comment, '%class', class, 'g') let @@ = comment normal ""P let @@ = reg_save endfunction "let g:endtagcommentFormat = '<!-- /%tag_name%id%class -->' "" keymap nnoremap ,ti :<C-u>call Endtagcomment('id')<CR> nnoremap ,tc :<C-u>call Endtagcomment('class')<CR> nnoremap ,ta :<C-u>call Endtagcomment('id_class')<CR> "nnoremap ,tg :<C-u>call Endtagcomment('tag_id_class')<CR> nmap ,t :<C-u>normal ,tc<CR> nmap ,tt :<C-u>normal ,tc<CR> " コメント内のテキストの前後の空白 let g:endtagcomment_space = '' "" 有無をトグル function! Endtagcomment_space_toggle() let comment_space = g:endtagcomment_space if l:comment_space == '' let g:endtagcomment_space = ' ' else let g:endtagcomment_space = '' endif endfunction """ keymap nnoremap <silent> ,t<Space> :<C-u>call Endtagcomment_space_toggle()<CR> " コメント内のテキストの最初のclass名の「.」 let g:endtagcomment_firstclass_symbol = '' "" 有無をトグル(id+classの場合は固定で「.」がつきます) function! Endtagcomment_firstclass_symbol_toggle() let firstclass_symbol = g:endtagcomment_firstclass_symbol if l:firstclass_symbol == '' let g:endtagcomment_firstclass_symbol = '.' else let g:endtagcomment_firstclass_symbol = '' endif endfunction "" keymap nnoremap <silent> ,t. :<C-u>call Endtagcomment_firstclass_symbol_toggle()<CR> -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ " こういうHTMLがあったときに " <div id="hoge" class="fuga"> " ... " </div> " " 実行するとこうなる " <div id="hoge" class="fuga"> " ... " <!-- /div#hoge.fuga --></div> function! Endtagcomment() let reg_save = @@ -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,7 @@ function! Endtagcomment() let class = '.' . join(split(class_match[1], '\v\s+'), '.') endif execute "normal `>va<\<Esc>`<" let comment = g:endtagcommentFormat let comment = substitute(comment, '%tag_name', tag_name, 'g') -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -41,5 +41,5 @@ function! Endtagcomment() let @@ = reg_save endfunction let g:endtagcommentFormat = '<!-- /%tag_name%id%class -->' nnoremap ,t :<C-u>call Endtagcomment()<CR> -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 2 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,13 @@ function! Endtagcomment() let reg_save = @@ try silent normal vaty catch execute "normal \<Esc>" echohl ErrorMsg echo 'no match html tags' echohl None return endtry -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 10 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -27,20 +27,27 @@ function! Endtagcomment() let id = '' let id_match = matchlist(start_tag, '\vid\=["'']([^"'']+)["'']') if exists('id_match[1]') let id = '#' . id_match[1] endif let class = '' let class_match = matchlist(start_tag, '\vclass\=["'']([^"'']+)["'']') if exists('class_match[1]') let class = '.' . join(split(class_match[1], '\v\s+'), '.') endif execute "normal `]va<\<Esc>`<" let comment = g:endtagcommentFormat let comment = substitute(comment, '%tag_name', tag_name, 'g') let comment = substitute(comment, '%id', id, 'g') let comment = substitute(comment, '%class', class, 'g') let @@ = comment normal ""P let @@ = reg_save endfunction let g:endtagcommentFormat = '<!-- %tag_name%id%class -->' nnoremap ,t :<C-u>call Endtagcomment()<CR> -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ " <div id="hoge" class="fuga"> " ... " <!-- /div#hoge.fuga --></div> function! Endtagcomment() let reg_save = @@ -
hokaccha revised this gist
May 25, 2010 . 1 changed file with 30 additions and 14 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,29 +1,45 @@ " こういうHTMLがあったときに " <div id="hoge" class="fuga"> " ... " </div> " " 実行するとこうなる " <div id="hoge" class="fuga"> " ... " <!-- /div#hoge.fuga --></div> function! Endtagcomment() let reg_save = @@ try silent normal vaty catch execute "normal \<Esc>" echo 'no match html tags' return endtry let html = @@ let start_tag = matchstr(html, '\v(\<.{-}\>)') let tag_name = matchstr(start_tag, '\v([a-zA-Z]+)') let id = '' let id_match = matchlist(start_tag, '\vid\=["'']([^"'']+)["'']') if exists('id_match[1]') let id = '#' . id_m[1] endif let class = '' let class_match = matchlist(start_tag, '\vclass\=["'']([^"'']+)["'']') if exists('class_match[1]') let class = '.' . join(split(class_m[1], '\v\s+'), '.') endif execute "normal `]va<\<Esc>`<" let @@ = printf('<!-- /%s%s%s -->', tag_name, id, class) normal ""P let @@ = reg_save endfunction nnoremap ,t :<C-u>call Endtagcomment()<CR> -
hokaccha revised this gist
May 24, 2010 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,8 @@ function! g:endtagcomment() endif call setpos('.', tmp_pos) execute "normal vat\<ESC>" normal va<y let @@ = printf('<!-- /%s%s%s -->', tag_name, id, class) normal ""P -
hokaccha revised this gist
May 24, 2010 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ function! g:endtagcomment() let tmp = @@ let tmp_pos = getpos('.') silent normal vaty 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\=["'']([^"'']+)["'']') @@ -18,8 +18,8 @@ function! g:endtagcomment() endif call setpos('.', tmp_pos) let @@ = printf('<!-- /%s%s%s -->', tag_name, id, class) normal ""P let @@ = tmp endfunction -
hokaccha revised this gist
May 24, 2010 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,8 +18,8 @@ function! g:endtagcomment() endif call setpos('.', tmp_pos) let @y = printf('<!-- /%s%s%s -->', tag_name, id, class) normal "yP let @@ = tmp endfunction -
hokaccha revised this gist
May 24, 2010 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ function! g:endtagcomment() endif call setpos('.', tmp_pos) let @@ = printf('<!-- /%s%s%s -->', tag_name, id, class) normal P let @@ = tmp -
hokaccha created this gist
May 24, 2010 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ 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 @@ = printf('<!-- %s%s%s -->', tag_name, id, class) normal P let @@ = tmp endfunction nnoremap ,t :<C-u>call g:endtagcomment()<CR>