" Add/substracts a number from all the characters in a text object. " " [count]cx - increment all the characters in the text object by count, " except whitespace " [count]cX - decrement all characters in the text object by count, except " whitespace " [count]cgx - like cx, but include whitespace characters " [count]cgX - like cX, but include whitespace characters " " The following convinence functions are added " " cxx, cXX, cgxx, cgXX to operate on lines. " noremap cx call set_dir(v:count1,0)set operatorfunc=charaddg@ nnoremap cxx call set_dir(v:count1,0)set operatorfunc=charaddg@_ noremap cX call set_dir(-v:count1,0)set operatorfunc=charaddg@ nnoremap cXX call set_dir(-v:count1,0)set operatorfunc=charaddg@_ noremap cgx call set_dir(v:count1,1)set operatorfunc=charaddg@ nnoremap cgxx call set_dir(v:count1,1)set operatorfunc=charaddg@_ noremap cgX call set_dir(-v:count1,1)set operatorfunc=charaddg@ nnoremap cgXX call set_dir(-v:count1,1)set operatorfunc=charaddg@_ let s:dir = 1 let s:incl = 0 function! s:set_dir(d, i) abort let s:dir = a:d let s:incl = a:i endfunction function! s:charadd(arg, ...) abort let save_a = getreg('a') let save_a_type = getregtype('a') if a:0 echo a:1 let vis = '`<' . a:arg . '`>' elseif a:arg == 'line' let vis = "'[V']" elseif a:arg == 'block' let vis = "`[\`]" else let vis = "`[v`]" endif silent! exec printf("norm! %s\"ay", vis) let r = getreg('a', 1) let rtyp = getregtype('a') let nl = "" for c in r if s:incl || ! (c =~ '\_s') let n = char2nr(c) let nl .= nr2char(n + s:dir) else let nl .= c endif endfor call setreg('a', nl, rtyp) silent! exec printf("norm! gv\"ap`[") call setreg('a', save_a, save_a_type) endfunction