VIM:アドバンテージを拡大して深める

ブロガーを支援するいくつかの機能とvimコマンド。

彼らは何をしていますか?
二重のマイナスとマイナスを、端 スペースがある長いダッシュ ( —)の不可解なスペースに変更し 、引用符「クリスマスツリー」に引用符「秒」を付けます。

使い方は?
コードを.vimrcにコピーし、vimを開いて、次のように記述します。
 浸透しますが、小さい名前は「E-Type」です。 

次に、コマンドモードで:
  :HTMLLineRU <CR> 

どこで
  --    Enter. 
:
, &laquo;E-Type&raquo;&nbsp;&mdash; !
:

, «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, '\&nbsp;\&mdash; ', "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, '\&laquo;'.escape(matched, '\&*[]?%').'\&raquo;', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\&laquo;', "g") let patt = '»' let line = substitute(line, patt, '\&raquo;', "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.
:
, &laquo;E-Type&raquo;&nbsp;&mdash; !
:

, «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, '\&nbsp;\&mdash; ', "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, '\&laquo;'.escape(matched, '\&*[]?%').'\&raquo;', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\&laquo;', "g") let patt = '»' let line = substitute(line, patt, '\&raquo;', "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. 
:
, &laquo;E-Type&raquo;&nbsp;&mdash; !
:

, «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, '\&nbsp;\&mdash; ', "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, '\&laquo;'.escape(matched, '\&*[]?%').'\&raquo;', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\&laquo;', "g") let patt = '»' let line = substitute(line, patt, '\&raquo;', "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.
:
, &laquo;E-Type&raquo;&nbsp;&mdash; !
:

, «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, '\&nbsp;\&mdash; ', "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, '\&laquo;'.escape(matched, '\&*[]?%').'\&raquo;', "") let matched = matchstr(line, patt_match) endwhile let patt = '«' let line = substitute(line, patt, '\&laquo;', "g") let patt = '»' let line = substitute(line, patt, '\&raquo;', "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/J29725/


All Articles