Add mapping feature

This commit is contained in:
Vlad Chepaykyn 2020-06-29 01:19:26 +03:00
parent c947ad2b6a
commit 12bd98cb59
2 changed files with 20 additions and 23 deletions

View file

@ -44,11 +44,6 @@
" \ call <SID>MyFunction(v:register, ...)<Bar>
" \ silent! call repeat#set("\<lt>Plug>MyMap")<CR>
if exists("g:loaded_repeat") || &cp || v:version < 700
finish
endif
let g:loaded_repeat = 1
let g:repeat_tick = -1
let g:repeat_reg = ['', '']
@ -138,24 +133,6 @@ function! repeat#wrap(command,count)
endif
endfunction
nnoremap <silent> <Plug>(RepeatDot) :<C-U>exe repeat#run(v:count)<CR>
nnoremap <silent> <Plug>(RepeatUndo) :<C-U>call repeat#wrap('u',v:count)<CR>
nnoremap <silent> <Plug>(RepeatUndoLine) :<C-U>call repeat#wrap('U',v:count)<CR>
nnoremap <silent> <Plug>(RepeatRedo) :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
if !hasmapto('<Plug>(RepeatDot)', 'n')
nmap . <Plug>(RepeatDot)
endif
if !hasmapto('<Plug>(RepeatUndo)', 'n')
nmap u <Plug>(RepeatUndo)
endif
if maparg('U','n') ==# '' && !hasmapto('<Plug>(RepeatUndoLine)', 'n')
nmap U <Plug>(RepeatUndoLine)
endif
if !hasmapto('<Plug>(RepeatRedo)', 'n')
nmap <C-R> <Plug>(RepeatRedo)
endif
augroup repeatPlugin
autocmd!
autocmd BufLeave,BufWritePre,BufReadPre * let g:repeat_tick = (g:repeat_tick == b:changedtick || g:repeat_tick == 0) ? 0 : -1

20
plugin/repeat.vim Normal file
View file

@ -0,0 +1,20 @@
if exists("g:loaded_repeat") || &cp || v:version < 700
finish
endif
let g:loaded_repeat = 1
nnoremap <silent> <Plug>(RepeatDot) :<C-U>exe repeat#run(v:count)<CR>
nnoremap <silent> <Plug>(RepeatUndo) :<C-U>call repeat#wrap('u',v:count)<CR>
nnoremap <silent> <Plug>(RepeatUndoLine) :<C-U>call repeat#wrap('U',v:count)<CR>
nnoremap <silent> <Plug>(RepeatRedo) :<C-U>call repeat#wrap("\<Lt>C-R>",v:count)<CR>
if !exists('g:repeat_no_default_key_mappings') || !g:repeat_no_default_key_mappings
nmap . <Plug>(RepeatDot)
nmap u <Plug>(RepeatUndo)
nmap U <Plug>(RepeatUndoLine)
nmap <C-R> <Plug>(RepeatRedo)
endif
" vim:set ft=vim et sw=4 sts=4: