📜 âŹ†ïž âŹ‡ïž

VIM: Expand and deepen to your advantage

A couple of functions and a Vim command (command) to help the blogger.

What are they doing?
They change double minus and minus with a space around the edges for an unbreakable space with a long dash (& nbsp; & mdash;), quotes “seconds” for quotes “herringbone”.

How to use it?
Copy the code into your .vimrc, open vim, write:
  It will instill, less name is "E-Type" −- to health! 

Then in command mode:
  : HTMLLineRU <CR> 

Where
  --    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/29725/


All Articles