aboutsummaryrefslogtreecommitdiff
path: root/plugin/charadd.vim
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/charadd.vim')
-rw-r--r--plugin/charadd.vim43
1 files changed, 14 insertions, 29 deletions
diff --git a/plugin/charadd.vim b/plugin/charadd.vim
index b1d0912..02bd626 100644
--- a/plugin/charadd.vim
+++ b/plugin/charadd.vim
@@ -46,35 +46,20 @@ function! s:set_dir(d, i) abort
endfunction
function! s:charadd(arg, ...) abort
- let save_a = getreg('a')
- let save_a_type = getregtype('a')
+ let cb = {'as_chars': 1}
- if a:0
- echo a:1
- let vis = '`<' . a:arg . '`>'
- elseif a:arg == 'line'
- let vis = "'[V']"
- elseif a:arg == 'block'
- let vis = "`[\<C-v>`]"
- else
- let vis = "`[v`]"
- endif
+ 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
- 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)
+ call fieldmarshal#modifytext(a:arg, cb)
endfunction