easymotion / vim-easymotion

Vim motions on speed!
http://www.vim.org/scripts/script.php?script_id=3526
7.5k stars 362 forks source link

Prioritise (promote) the last-typed character in `keys` for the sneak-style motions #357

Open ELLIOTTCABLE opened 6 years ago

ELLIOTTCABLE commented 6 years ago

@justinmk copied a feature from clever-f.vim to vim-sneak, that allows one to repeat the mapping (hit s again after an s, for instance) to reach further instances of the pair.

This doesn't map directly to EasyMotion, in which further instances are reached by direct entry of a character from g:EasyMotion_keys; but I believe similar usability can be achieved with one simple modification:

Prepend the last character of an N-character sneak to g:EasyMotion_keys.

So, if I type sle, and there are several instances of le — the nearest key I could possibly hit, is the one my finger is already over: e! Thus, I propose we promote e, if it exists in g:EasyMotion_keys at all, to the front of g:EasyMotion_keys, so that the very first-nearest result is always instantly accessible by repeating the last character of your search: slee.


This is especially useful when replacing fFtT with EasyMotion movements, as I have:

nmap f <Plug>(easymotion-fl) | xmap f <Plug>(easymotion-fl) | omap f <Plug>(easymotion-fl)
nmap F <Plug>(easymotion-Fl) | xmap F <Plug>(easymotion-Fl) | omap F <Plug>(easymotion-Fl)
nmap t <Plug>(easymotion-tl) | xmap t <Plug>(easymotion-tl) | omap t <Plug>(easymotion-tl)
nmap T <Plug>(easymotion-Tl) | xmap T <Plug>(easymotion-Tl) | omap T <Plug>(easymotion-Tl)

With the above suggestion, in the extremely-common case that “I just want to jump to the next [, then when typing f[, if there's more than one result, your finger is already hovering over the key that will get you where you wanted to go: f[[.