vim-patch:0e6adf8a29d5

Update runtime files

0e6adf8a29

Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
zeertzjq 2022-12-07 14:11:26 +08:00
parent 7dfd466437
commit c61af03cd2

View File

@ -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