vim中创建可重复的映射
可以通过g@传递它们来创建可重复映射
function! s:insspace(...)
if a:0
execute 'normal' v:count1.'i '."\<esc>".'`['
else
" 安装"
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return "g@\<space>"
endif
endfunction
nnoremap <silent><expr> <space> <sid>insspace()
通常g@用于运算符,但通过使用g@<space>,可为实际操作.这里实际上调用了两次s:insspace函数,一次无参数,意思是"设置",它设置operatorfunc选项为自己(类似matchstr),然后由vim用一个参数再次调用.
浙公网安备 33010602011771号