It will instill, less name is "E-Type" â- to health!
: HTMLLineRU <CR>
-- Enter.
:
, «E-Type» — !
:
, «E-Type» â !
:
" HTML typo {{{ "" Convert text line to HTML line function! HTMLLineRU(line) "" convert to hello â world: "" hello â- world "" hello--world "" hello - world let patt = '\(\s*--\s*\)\|\( - \)\|\(\s*â\s*\)' let line = substitute(a:line, patt, '\ \— ', "g") "" «russian quotes» "" convert "hello world" to «hello world» let patt_match = '"\zs.\{-}\ze"' let patt_subs = '".\{-}"' let matched = matchstr(line, patt_match) while matched != "" let line = substitute(line, patt_subs, '\«'.escape(matched, '\&*[]?%').'\»', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\«', "g") let patt = '»' let line = substitute(line, patt, '\»', "g") return line endfunction function! HTMLLines(line1, line2) let sourceLines = getline(a:line1, a:line2) if bufloaded("scratch_html_lines") :bdelete html_lines endif :new scratch_html_lines :setlocal buftype=nofile :setlocal noswapfile let lineidx = 1 for line in sourceLines call setline(lineidx, HTMLLineRU(line)) let lineidx+=1 endfor endfunction command! -range=% HTMLLineRU call HTMLLines(expand(<line1>), expand(<line2>)) " }}}
PS
, . :)
PPS
wiki , , * * .
PPPS
vim ? :)
-- Enter.
:
, «E-Type» — !
:
, «E-Type» â !
:
" HTML typo {{{ "" Convert text line to HTML line function! HTMLLineRU(line) "" convert to hello â world: "" hello â- world "" hello--world "" hello - world let patt = '\(\s*--\s*\)\|\( - \)\|\(\s*â\s*\)' let line = substitute(a:line, patt, '\ \— ', "g") "" «russian quotes» "" convert "hello world" to «hello world» let patt_match = '"\zs.\{-}\ze"' let patt_subs = '".\{-}"' let matched = matchstr(line, patt_match) while matched != "" let line = substitute(line, patt_subs, '\«'.escape(matched, '\&*[]?%').'\»', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\«', "g") let patt = '»' let line = substitute(line, patt, '\»', "g") return line endfunction function! HTMLLines(line1, line2) let sourceLines = getline(a:line1, a:line2) if bufloaded("scratch_html_lines") :bdelete html_lines endif :new scratch_html_lines :setlocal buftype=nofile :setlocal noswapfile let lineidx = 1 for line in sourceLines call setline(lineidx, HTMLLineRU(line)) let lineidx+=1 endfor endfunction command! -range=% HTMLLineRU call HTMLLines(expand(<line1>), expand(<line2>)) " }}}
PS
, . :)
PPS
wiki , , * * .
PPPS
vim ? :)
-- Enter.
:
, «E-Type» — !
:
, «E-Type» â !
:
" HTML typo {{{ "" Convert text line to HTML line function! HTMLLineRU(line) "" convert to hello â world: "" hello â- world "" hello--world "" hello - world let patt = '\(\s*--\s*\)\|\( - \)\|\(\s*â\s*\)' let line = substitute(a:line, patt, '\ \— ', "g") "" «russian quotes» "" convert "hello world" to «hello world» let patt_match = '"\zs.\{-}\ze"' let patt_subs = '".\{-}"' let matched = matchstr(line, patt_match) while matched != "" let line = substitute(line, patt_subs, '\«'.escape(matched, '\&*[]?%').'\»', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\«', "g") let patt = '»' let line = substitute(line, patt, '\»', "g") return line endfunction function! HTMLLines(line1, line2) let sourceLines = getline(a:line1, a:line2) if bufloaded("scratch_html_lines") :bdelete html_lines endif :new scratch_html_lines :setlocal buftype=nofile :setlocal noswapfile let lineidx = 1 for line in sourceLines call setline(lineidx, HTMLLineRU(line)) let lineidx+=1 endfor endfunction command! -range=% HTMLLineRU call HTMLLines(expand(<line1>), expand(<line2>)) " }}}
PS
, . :)
PPS
wiki , , * * .
PPPS
vim ? :)
-- Enter.
:
, «E-Type» — !
:
, «E-Type» â !
:
" HTML typo {{{ "" Convert text line to HTML line function! HTMLLineRU(line) "" convert to hello â world: "" hello â- world "" hello--world "" hello - world let patt = '\(\s*--\s*\)\|\( - \)\|\(\s*â\s*\)' let line = substitute(a:line, patt, '\ \— ', "g") "" «russian quotes» "" convert "hello world" to «hello world» let patt_match = '"\zs.\{-}\ze"' let patt_subs = '".\{-}"' let matched = matchstr(line, patt_match) while matched != "" let line = substitute(line, patt_subs, '\«'.escape(matched, '\&*[]?%').'\»', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\«', "g") let patt = '»' let line = substitute(line, patt, '\»', "g") return line endfunction function! HTMLLines(line1, line2) let sourceLines = getline(a:line1, a:line2) if bufloaded("scratch_html_lines") :bdelete html_lines endif :new scratch_html_lines :setlocal buftype=nofile :setlocal noswapfile let lineidx = 1 for line in sourceLines call setline(lineidx, HTMLLineRU(line)) let lineidx+=1 endfor endfunction command! -range=% HTMLLineRU call HTMLLines(expand(<line1>), expand(<line2>)) " }}}
PS
, . :)
PPS
wiki , , * * .
PPPS
vim ? :)
Source: https://habr.com/ru/post/29725/
All Articles