\£d ciW:exe 'norm a' . b:div_class . ">
\evitholp2EB"
vnoremap \d c:exe 'norm a' . b:div_class . ">
\evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_td()
let @t="I \ | \+EB"
nnoremap \£t ciW:exe 'norm a' . b:td_class . "> | \evitholp2EB"
vnoremap \t c:exe 'norm a' . b:td_class . "> | \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_a()
let @a="^y$i \ \+EB"
nnoremap \£a ciWgP:exe 'norm a' . b:a_class . "> \evitholp2EB"
vnoremap \a cgP:exe 'norm a' . b:a_class . "> \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_span()
let @s="I \ \+EB"
nnoremap \£s ciW:exe 'norm a' . b:span_class . "> \evitholp2EB"
vnoremap \s c:exe 'norm a' . b:span_class . "> \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_h1()
let @h="I \
\+EB"
nnoremap \£h ciW:exe 'norm a' . b:h1_class . ">
\evitholp2EB"
vnoremap \h c:exe 'norm a' . b:h1_class . ">
\evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_i()
let @i="i\`[2Ei"
endfunction
function! Init_em()
let @e="I \ \+EB"
nnoremap \£e ciW:exe 'norm a' . b:em_class . "> \evitholp2EB"
vnoremap \e c:exe 'norm a' . b:em_class . "> \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_b()
let @b="I \ \+EB"
nnoremap \£b ciW:exe 'norm a' . b:b_class . "> \evitholp2EB"
vnoremap \b c:exe 'norm a' . b:b_class . "> \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
function! Init_li()
let @l="I \ \+EB"
nnoremap \£l ciW:exe 'norm a' . b:li_class . "> \evitholp2EB"
vnoremap \l c:exe 'norm a' . b:li_class . "> \evitholgpvatov:s/\\s\\+$//ge\r=atvatv"
endfunction
call Init_ul ()
call Init_ol ()
call Init_p ()
call Init_div ()
call Init_td ()
call Init_a ()
call Init_span()
call Init_h1 ()
call Init_i ()
call Init_em ()
call Init_b ()
call Init_li ()
" Set the class of a tag {{{2
" ---------------------------
function! SetClass(tag, ...)
if 'ul' == a:tag || 'u' == a:tag
if !exists("a:1")
let b:ul_class = ''
else
let b:ul_class = " class='" . a:1 . "'"
endif
call Init_ul()
elseif 'ol' == a:tag || 'o' == a:tag
if !exists("a:1")
let b:ol_class = ''
else
let b:ol_class = " class='" . a:1 . "'"
endif
call Init_ol()
elseif 'p' == a:tag
if !exists("a:1")
let b:p_class = ''
else
let b:p_class = " class='" . a:1 . "'"
endif
call Init_p()
elseif 'div' == a:tag || 'd' == a:tag
if !exists("a:1")
let b:div_class = ''
else
let b:div_class = " class='" . a:1 . "'"
endif
call Init_div()
elseif 'td' == a:tag || 't' == a:tag
if !exists("a:1")
let b:td_class = ''
else
let b:td_class = " class='" . a:1 . "'"
endif
call Init_td()
elseif 'a' == a:tag
if !exists("a:1")
let b:a_class = ''
else
let b:a_class = " class='" . a:1 . "'"
endif
call Init_a()
elseif 'span' == a:tag || 's' == a:tag
if !exists("a:1")
let b:span_class = ''
else
let b:span_class = " class='" . a:1 . "'"
endif
call Init_span()
elseif 'h1' == a:tag || 'h' == a:tag
if !exists("a:1")
let b:h1_class = ''
else
let b:h1_class = " class='" . a:1 . "'"
endif
call Init_h1()
elseif 'img' == a:tag || 'i' == a:tag
if !exists("a:1")
let b:i_class = ''
else
let b:i_class = " class='" . a:1 . "'"
endif
call Init_i()
elseif 'em' == a:tag || 'e' == a:tag
if !exists("a:1")
let b:em_class = ''
else
let b:em_class = " class='" . a:1 . "'"
endif
call Init_i()
elseif 'strong' == a:tag || 'b' == a:tag
if !exists("a:1")
let b:b_class = ''
else
let b:b_class = " class='" . a:1 . "'"
endif
call Init_b()
elseif 'li' == a:tag || 'l' == a:tag
if !exists("a:1")
let b:li_class = ''
else
let b:li_class = " class='" . a:1 . "'"
endif
call Init_li()
endif
endfunction
command! -complete=customlist,HtmlTags -nargs=+ Class :call SetClass()
function! HtmlTags(A,L,P)
return ['div ', 'span ', 'ul ', 'ol ', 'h1 ', 'li ', 'td ', 'img ', 'em ', 'strong ', 'a ', 'p ']
endfunction
" Close an opening tag {{{2
" -------------------------
" Each tag on a new line
inoremap >> > >4hvi4l"*p`[3hrO
" Both tags on the same line
inoremap >/ >>3hvi3l"*pcit
inoremap
" Wrap a line, a WORD or a selection with {{{2
" -----------------------------------------------------
let @c="I\+EB"
nnoremap \£c ciWEB
vnoremap \c cB2hvgpv?\?>v?\?>/s-1v?\?>=jgqqjoEB:noh
nnoremap \r @='\£r'
" Strip outer tags {{{2
" ---------------------
let @x="vitdvatpgv:s/\\s\\+$//ge\gv=`>EB"
nnoremap \£x ?\_.\=\?>/s-1v?\?>/epgv=`>EB:noh
nnoremap \x @='\£x'
" 'Space' content of a pair of tags {{{2
" --------------------------------------
let @m="vitgeowVc\\P-=at']+EB"
nnoremap \£m ?\_.\=\?>O+v?