1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| # ReferenceLine
fu! ReferenceLine(t) if exists('w:ccnum') let ccnum=w:ccnum elsei exists('b:ccnum') let ccnum=b:ccnum else let ccnum=0 en let oldcc=ccnum let ccc=','.&cc.',' if a:t=='add' || a:t=='sub' if match(ccc, ','.oldcc.',')<0 let oldcc=0 let ccnum=0 en let csw=&sw if a:t=='add' let ccnum=ccnum + csw elsei a:t=='sub' let ccnum=ccnum - csw if ccnum < 0 | let ccnum=0 | en en if oldcc > 0 | let ccc=substitute(ccc, ','.oldcc.',', ',', '') | en let ccc=ccc.ccnum let ccc=substitute(ccc, '^0,\|,0,\|,0$', ',', 'g') let ccc=substitute(ccc, '^,\+\|,\+$', '', 'g') let w:ccnum=ccnum let b:ccnum=ccnum exec "setl cc=".ccc elsei a:t=='del' let ccc=substitute(ccc, ','.oldcc.',', ',', '') let ccc=substitute(ccc, '^,\+\|,\+$', '', 'g') let w:ccnum=0 let b:ccnum=0 exec "setl cc=".ccc en endf nn <silent> <A-u> :call ReferenceLine('sub')<CR> nn <silent> <A-o> :call ReferenceLine('add')<CR>
|