" 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. " if !exists('g:charadd_include_bindings') let g:charadd_include_bindings = 1 endif noremap (add-char) call set_dir( v:count1,0)set operatorfunc=charaddg@ nnoremap (add-char-line) call set_dir( v:count1,0)set operatorfunc=charaddg@_ noremap (sub-char) call set_dir(-v:count1,0)set operatorfunc=charaddg@ nnoremap (sub-char-line) call set_dir(-v:count1,0)set operatorfunc=charaddg@_ noremap (add-char-all) call set_dir( v:count1,1)set operatorfunc=charaddg@ nnoremap (add-char-all-line) call set_dir( v:count1,1)set operatorfunc=charaddg@_ noremap (sub-char-all) call set_dir(-v:count1,1)set operatorfunc=charaddg@ nnoremap (sub-char-all-line) call set_dir(-v:count1,1)set operatorfunc=charaddg@_ if g:charadd_include_bindings noremap cx (add-char) noremap cxx (add-char-line) noremap cX (sub-char) noremap cXX (sub-char-line) noremap cgx (add-char-all) noremap cgxx (add-char-all-line) noremap cgX (sub-char-all) noremap cgXX (sub-char-all-line) endif 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 cb = {'as_chars': 1} function cb.operate(l, ...) let nl = "" for c in a:l if s:incl || ! (c =~ '\_s') let n = char2nr(c) let nl .= nr2char(n + s:dir) else let nl .= c endif endfor return nl endfunction call fieldmarshal#modifytext(a:arg, cb) endfunction