Open kiryph opened 6 years ago
For
- extend only fFtT to include counts in ;, when counts used for fFtT, e.g. 2fe
see #5
Default setups seem useful, not sure yet how to present this to the user. And how to combine this with the <Plug>]]-motion
approach.
And maybe: some easy toggling during session (disabling should be as easy as enabling).
Maybe: detection of supported plugins during session (when everything is loaded), creating a config variable that can be put in the vimrc (something like that).
Suggestions?
For GitGutter users:
:nmap <expr> ]c repmo#Key('<Plug>GitGutterNextHunk', '<Plug>GitGutterPrevHunk')
:nmap <expr> [c repmo#Key('<Plug>GitGutterPrevHunk', '<Plug>GitGutterNextHunk')
I would present it as:
" Repeat the last [count]motion or the last zap-key:
:map <expr> ; repmo#LastKey(';')|sunmap ;
:map <expr> , repmo#LastRevKey(',')|sunmap ,
" include count in ; and , for fFtT which is not the case in default vim
for key in [ 'f', 'F', 't', 'T']
execute 'noremap <expr> '.key." repmo#ZapKey('".key."')|sunmap ".key
endfor
" nmap
for keys in [ ['<C-E>', '<C-Y>'], ['<C-B>', '<C-F>'], ['<C-D>', '<C-U>'] ]
execute 'nmap <expr> '.keys[0]." repmo#SelfKey('".keys[0]."', '".keys[1]."')"
execute 'nmap <expr> '.keys[1]." repmo#SelfKey('".keys[1]."', '".keys[0]."')"
endfor
" noremap and sunmap
for keys in [ ['h', 'l'], ['w', 'b'], ['W', 'B'], ['e', 'ge'], ['E', 'gE'],
\ ['j', 'k'], ['gj', 'gk'], ['-', '+'], ['(', ')'], ['{', '}'], ['[[', ']]'],
\ ['[]', ']['], ['[m', ']m'], ['[M', ']M'], ['[{', ']}'], ['[(', '])'],
\ ['[s', ']s'], ['[S', ']S'], ['[*', ']*'], ['[/', ']/'], ['[#', ']#'],
\ ['[z', ']z'], ['zj', 'zk'], ['zh', 'zl'] ]
execute 'noremap <expr> '.keys[0]." repmo#SelfKey('".keys[0]."', '".keys[1]."')|sunmap ".keys[0]
execute 'noremap <expr> '.keys[1]." repmo#SelfKey('".keys[1]."', '".keys[0]."')|sunmap ".keys[1]
endfor
Note I added zh
/ zl
for moving the viewport left/right.
Using https://github.com/Houl/repmohelper-vim:
" :PutRepmoSelfMap <C-E>|<C-Y> <C-B>|<C-F> <C-D>|<C-U>
noremap <expr> <C-E> repmo#SelfKey('<C-E>', '<C-Y>')|sunmap <C-E>
noremap <expr> <C-Y> repmo#SelfKey('<C-Y>', '<C-E>')|sunmap <C-Y>
noremap <expr> <C-B> repmo#SelfKey('<C-B>', '<C-F>')|sunmap <C-B>
noremap <expr> <C-F> repmo#SelfKey('<C-F>', '<C-B>')|sunmap <C-F>
noremap <expr> <C-D> repmo#SelfKey('<C-D>', '<C-U>')|sunmap <C-D>
noremap <expr> <C-U> repmo#SelfKey('<C-U>', '<C-D>')|sunmap <C-U>
" :PutRepmoSelfMap j|k gj|gk -|+
noremap <expr> j repmo#SelfKey('j', 'k')|sunmap j
noremap <expr> k repmo#SelfKey('k', 'j')|sunmap k
noremap <expr> gj repmo#SelfKey('gj', 'gk')|sunmap gj
noremap <expr> gk repmo#SelfKey('gk', 'gj')|sunmap gk
noremap <expr> - repmo#SelfKey('-', '+')|sunmap -
noremap <expr> + repmo#SelfKey('+', '-')|sunmap +
" ... and so on ...
" Matchup
" :PutRepmoMap <Plug>(matchup-<_>) %|g% [%|]%
map <expr> % repmo#Key('<Plug>(matchup-%)', '<Plug>(matchup-g%)')|sunmap %
map <expr> g% repmo#Key('<Plug>(matchup-g%)', '<Plug>(matchup-%)')|sunmap g%
map <expr> [% repmo#Key('<Plug>(matchup-[%)', '<Plug>(matchup-]%)')|sunmap [%
map <expr> ]% repmo#Key('<Plug>(matchup-]%)', '<Plug>(matchup-[%)')|sunmap ]%
" Vimtex
function! Repmo_vimtex()
" :PutRepmoMap <buffer> <Plug>(vimtex-<_>) ]]|[[ ][|[]
map <expr><buffer> ]] repmo#Key('<Plug>(vimtex-]])', '<Plug>(vimtex-[[)')|sunmap <buffer> ]]
map <expr><buffer> [[ repmo#Key('<Plug>(vimtex-[[)', '<Plug>(vimtex-]])')|sunmap <buffer> [[
map <expr><buffer> ][ repmo#Key('<Plug>(vimtex-][)', '<Plug>(vimtex-[])')|sunmap <buffer> ][
map <expr><buffer> [] repmo#Key('<Plug>(vimtex-[])', '<Plug>(vimtex-][)')|sunmap <buffer> []
endfunction
@kiryph I can't seem to get the unimpaired bindings working.
What do you get with :verbose map ]l
?
I get:
n ]l <Plug>unimpairedLNext
Last set from ~/.local/share/vim/bundle/vim-unimpaired/plugin/unimpaired.vim
Press ENTER or type command to continue
This is using:
nmap <expr> ]l repmo#Key('<plug>unimpairedLNext', '<plug>unimpairedLPrevious')
I had to place the unimpaired bindings using repmo into ~/.vim/after/plugin/repmo-unimpaired.vim
(filename is up to you except the file extension .vim
).
Otherwise vim-unimpaired itself has the last word. It looks like this is the case for you as well.
For comparison, I get:
n ]l repmo#Key('<Plug>unimpairedLNext', '<Plug>unimpairedLPrevious')
Last set from ~/.vim-configs/mwe-repmo-vim/after/plugin/repmo-unimpaired.vim line 5
Thanks @kiryph for the reply!
It works fine with gitgutter
, so I assume there's something that in unimparied
that's... impaired.
As a user it would be nice to have more suggestions in README.md how to extend other builtin motions and support third party motions.
Following list tries to be comprehensive w.r.t. built-in motions (grouped thematically, e.g. folds, spelling, horizontal movement, ...):
Selected third party
Suggested setups
One could suggest following different setups:
1) extend only
fFtT
to include counts in ;, when counts used for fFtT, e.g. 2fe 2) extend for other horizontal movements h,l; w,b; W,B; e,ge; E,gE (in particular useful for ge,gE) 3) extend for two-letter movements, e.g. zj,zk; gj,gk 4) extend for two-key movements, e.g. '{,}' (=Shift+[) or CTRL-E/Y 5) extend for ]-movements, e.g.]M
and[M
6) apply for all builtin movements