aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-07 14:11:26 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-07 14:25:58 +0800
commitc61af03cd2c310c1ee472b4529c34f6656574770 (patch)
treee15277a87e16b4443b252b9e9633549419484b7d
parent7dfd466437d506d800c7db12cc8a111357e13aff (diff)
downloadrneovim-c61af03cd2c310c1ee472b4529c34f6656574770.tar.gz
rneovim-c61af03cd2c310c1ee472b4529c34f6656574770.tar.bz2
rneovim-c61af03cd2c310c1ee472b4529c34f6656574770.zip
vim-patch:0e6adf8a29d5
Update runtime files https://github.com/vim/vim/commit/0e6adf8a29d5c2c96c42cc7157f71bf22c2ad471 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--runtime/doc/map.txt21
1 files changed, 14 insertions, 7 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt
index 2ecfefca7f..b495b355cf 100644
--- a/runtime/doc/map.txt
+++ b/runtime/doc/map.txt
@@ -872,28 +872,35 @@ Here is an example that counts the number of spaces with <F4>: >
" doubling <F4> works on a line
nnoremap <expr> <F4><F4> CountSpaces() .. '_'
- function CountSpaces(type = '') abort
+ function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort
if a:type == ''
- set opfunc=CountSpaces
+ let &operatorfunc = function('CountSpaces', [&virtualedit, v:false])
+ set virtualedit=block
return 'g@'
endif
+ let cb_save = &clipboard
let sel_save = &selection
let reg_save = getreginfo('"')
- let cb_save = &clipboard
let visual_marks_save = [getpos("'<"), getpos("'>")]
try
- set clipboard= selection=inclusive
- let commands = #{line: "'[V']y", char: "`[v`]y", block: "`[\<c-v>`]y"}
- silent exe 'noautocmd keepjumps normal! ' .. get(commands, a:type, '')
- echom count(getreg('"'), ' ')
+ set clipboard= selection=inclusive virtualedit=
+ let commands = #{line: "'[V']", char: "`[v`]", block: "`[\<C-V>`]"}->get(a:type, 'v')
+ if getpos("']")[-1] != 0 || a:irregular_block
+ let commands ..= 'oO$'
+ let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true])
+ endif
+ let commands ..= 'y'
+ execute 'silent noautocmd keepjumps normal! ' .. commands
+ echomsg getreg('"')->count(' ')
finally
call setreg('"', reg_save)
call setpos("'<", visual_marks_save[0])
call setpos("'>", visual_marks_save[1])
let &clipboard = cb_save
let &selection = sel_save
+ let &virtualedit = a:virtualedit
endtry
endfunction