diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2022-08-30 20:49:24 -0600 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2022-08-30 20:49:24 -0600 |
commit | 710a7b0a78d558594434aa78a6c8c46e6660f836 (patch) | |
tree | 5cc796770e19bfc32190869d8fc8f0945e8df2d3 /autoload | |
parent | 0d9030e66e6306a627ead0bd0bc404d5a5a8420a (diff) | |
download | fieldmarshal.vim-710a7b0a78d558594434aa78a6c8c46e6660f836.tar.gz fieldmarshal.vim-710a7b0a78d558594434aa78a6c8c46e6660f836.tar.bz2 fieldmarshal.vim-710a7b0a78d558594434aa78a6c8c46e6660f836.zip |
joiner.vim: add joiner.vim; verbs to join text.
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/joiner.vim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/autoload/joiner.vim b/autoload/joiner.vim new file mode 100644 index 0000000..6f59282 --- /dev/null +++ b/autoload/joiner.vim @@ -0,0 +1,38 @@ + +" Function for the operatorfunc with joiner. +function! joiner#do(type, ...) abort + if a:0 + silent exe "norm! gvy" + elseif a:type == 'line' + " yank the text described by the motion + silent exe "norm! '[V']y" + else + silent exe "norm! `[v`]y" + endif + + let yanked = getreg('"', 1, v:true) + let yankedtype = getregtype('"') + + let changed = [g:JoinerJoinText(yanked, yankedtype)] + + call setreg('"', changed, yankedtype) + + norm gvp + + " Reset the yanked text to what it was originally. + call setreg('"', yanked, yankedtype) +endfunction + +function! joiner#join_with_string(yanked, yanktype) abort + let join_string = input('> ') + return join(map(a:yanked, "substitute(v:val, '^\\s\\+', '', '')"), join_string) +endfunction + +function! joiner#join_with_string_literal(yanked, yanktype) abort + let join_string = input('> ') + return join(a:yanked, join_string) +endfunction + +function! joiner#default_join(yanked, yanktype) abort + return join(map(a:yanked, "substitute(v:val, '^\\s\\+', '', '')"), ' ') +endfunction |