So far, (and after many hours), I've come up with the following:
let g:lightspeed_last_motion = '' augroup lightspeed_last_motion autocmd! autocmd User LightspeedSxEnter let g:lightspeed_last_motion = 'sx' autocmd User LightspeedFtEnter let g:lightspeed_last_motion = 'ft' augroup end function! s:LightspeedRepeatMotion(direction) abort if index([';', ','], a:direction) < 0 echomsg 'Invalid direction ' . string(a:direction) . ' passed to ' . FnName() return endif if g:lightspeed_last_motion == 'sx' execute "normal \<Plug>Lightspeed_" . a:direction . '_sx' else " Default to ft execute "normal \<Plug>Lightspeed_" . a:direction . '_ft' endif endfunction noremap <Plug>Lightspeed_; :call <SID>LightspeedRepeatMotion(';')<CR> noremap <Plug>Lightspeed_, :call <SID>LightspeedRepeatMotion(',')<CR> map <expr> ; repmo#LastKey("<Plug>Lightspeed_;")|sunmap ; map <expr> , repmo#LastRevKey("<Plug>Lightspeed_,")|sunmap , map <expr> s repmo#ZapKey('<Plug>Lightspeed_s')|ounmap s|sunmap s map <expr> S repmo#ZapKey('<Plug>Lightspeed_S')|ounmap S|sunmap S omap <expr> z repmo#ZapKey('<Plug>Lightspeed_s') omap <expr> Z repmo#ZapKey('<Plug>Lightspeed_S') map <expr> f repmo#ZapKey('<Plug>Lightspeed_f')|sunmap f map <expr> F repmo#ZapKey('<Plug>Lightspeed_F')|sunmap F map <expr> t repmo#ZapKey('<Plug>Lightspeed_t')|sunmap t map <expr> T repmo#ZapKey('<Plug>Lightspeed_T')|sunmap T
FnName is defined here.
My problems with the above are:
When I try to repeat a motion by pressing
;, I see in the status area:
- Bottom left:
- Bottom right:
I want neither of these to display. My attempt at
Also, there is a delay, like vim is waiting for another keystroke - the cursor doesn't move immediately.
- Bottom left:
It doesn't work in
visualselection mode. I can't work out how to use
<Cmd>and still have the mappings work.
I don't like using global variable
g:lightspeed_last_motion. Different buffers should remember their last motion independent of each other. A simple rename to
b:doesn't work. How do I achieve this?