diff options
author | Bram Moolenaar <Bram@vim.org> | 2021-12-16 14:41:10 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2021-12-16 14:41:10 +0000 |
commit | 0e6adf8a29d5c2c96c42cc7157f71bf22c2ad471 (patch) | |
tree | 5c0d0406aa228d3d547f0293a438e2d49f762d12 /runtime/doc/map.txt | |
parent | 6df0f2759d12ec0bc999b2963ecea4387a2bc516 (diff) |
Update runtime files
Diffstat (limited to 'runtime/doc/map.txt')
-rw-r--r-- | runtime/doc/map.txt | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 981ecf7925..fc3f42584c 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1,4 +1,4 @@ -*map.txt* For Vim version 8.2. Last change: 2021 Nov 20 +*map.txt* For Vim version 8.2. Last change: 2021 Dec 15 VIM REFERENCE MANUAL by Bram Moolenaar @@ -173,7 +173,7 @@ type "a", then "bar" will get inserted. "<unique>" can be used in any order. They must appear right after the command, before any other arguments. - *:map-local* *:map-<buffer>* *E224* *E225* + *:map-local* *:map-<buffer>* *:map-buffer* *E224* *E225* If the first argument to one of these commands is "<buffer>" the mapping will be effective in the current buffer only. Example: > :map <buffer> ,w /[.,;]<CR> @@ -232,7 +232,7 @@ Note: ":map <script>" and ":noremap <script>" do the same thing. The "<script>" overrules the command name. Using ":noremap <script>" is preferred, because it's clearer that remapping is (mostly) disabled. - *:map-<unique>* *E226* *E227* + *:map-<unique>* *:map-unique* *E226* *E227* If the first argument to one of these commands is "<unique>" and it is used to define a new mapping or abbreviation, the command will fail if the mapping or abbreviation already exists. Example: > @@ -974,28 +974,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 + 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 getreg('"')->count(' ') + 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 |