Implement next/previous motion like ;
& ,
This commit is contained in:
parent
cb45856d7d
commit
6b77811186
@ -413,6 +413,20 @@ function! EasyMotion#DotRepeat(visualmode) " {{{
|
|||||||
silent call s:EasyMotion(re, direction, 0, is_exclusive)
|
silent call s:EasyMotion(re, direction, 0, is_exclusive)
|
||||||
endfor
|
endfor
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
function! EasyMotion#NextPrevious(visualmode, direction) " {{{
|
||||||
|
" Repeat previous motion with previous targets
|
||||||
|
if s:previous ==# {}
|
||||||
|
call s:Message("Previous targets doesn't exist")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let re = s:previous.regexp
|
||||||
|
let search_direction = (a:direction >= 1 ? 'b' : '')
|
||||||
|
|
||||||
|
for i in range(v:count1)
|
||||||
|
call searchpos(re, search_direction)
|
||||||
|
endfor
|
||||||
|
call EasyMotion#reset()
|
||||||
|
endfunction " }}}
|
||||||
" }}}
|
" }}}
|
||||||
" == Helper functions {{{
|
" == Helper functions {{{
|
||||||
" -- Message -----------------------------
|
" -- Message -----------------------------
|
||||||
|
@ -151,6 +151,8 @@ EasyMotion <Plug> table *easymotion-plug-table*
|
|||||||
<Plug>(easymotion-bd-n) | See |<Plug>(easymotion-bd-n)|
|
<Plug>(easymotion-bd-n) | See |<Plug>(easymotion-bd-n)|
|
||||||
<Plug>(easymotion-jumptoanywhere) | See |<Plug>(easymotion-jumptoanywhere)|
|
<Plug>(easymotion-jumptoanywhere) | See |<Plug>(easymotion-jumptoanywhere)|
|
||||||
<Plug>(easymotion-repeat) | See |<Plug>(easymotion-repeat)|
|
<Plug>(easymotion-repeat) | See |<Plug>(easymotion-repeat)|
|
||||||
|
<Plug>(easymotion-next) | See |<Plug>(easymotion-next)|
|
||||||
|
<Plug>(easymotion-previous) | See |<Plug>(easymotion-previous)|
|
||||||
<Plug>(easymotion-sol-j) | See |<Plug>(easymotion-sol-j)|
|
<Plug>(easymotion-sol-j) | See |<Plug>(easymotion-sol-j)|
|
||||||
<Plug>(easymotion-eol-j) | See |<Plug>(easymotion-eol-j)|
|
<Plug>(easymotion-eol-j) | See |<Plug>(easymotion-eol-j)|
|
||||||
|
|
|
|
||||||
@ -256,6 +258,19 @@ Repeat ~
|
|||||||
<Plug>(easymotion-j) etc...) but only repeat input
|
<Plug>(easymotion-j) etc...) but only repeat input
|
||||||
characters.
|
characters.
|
||||||
|
|
||||||
|
<Plug>(easymotion-next) *<Plug>(easymotion-next)*
|
||||||
|
<Plug>(easymotion-previous) *<Plug>(easymotion-previous)*
|
||||||
|
|
||||||
|
Jump to next/previous much. Only this motion can be move to offscrren
|
||||||
|
match. This motion wrap around the end of the file if you set
|
||||||
|
|'wrapscan'| in your vimrc.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
>
|
||||||
|
nmap <Leader>; <Plug>(easymotion-next)
|
||||||
|
nmap <Leader>, <Plug>(easymotion-previous)
|
||||||
|
<
|
||||||
|
|
||||||
EasyMotion dot repeat~
|
EasyMotion dot repeat~
|
||||||
*easymotion-dotrepeat* *easymotion-textobjct*
|
*easymotion-dotrepeat* *easymotion-textobjct*
|
||||||
|
|
||||||
|
@ -250,6 +250,18 @@ xnoremap <silent><Plug>(easymotion-dotrepeat)
|
|||||||
\ <Esc>:<C-u>call EasyMotion#DotRepeat(1)<CR>
|
\ <Esc>:<C-u>call EasyMotion#DotRepeat(1)<CR>
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
" -- Next,Previous Motion {{{
|
||||||
|
noremap <silent><Plug>(easymotion-next)
|
||||||
|
\ :<C-u>call EasyMotion#NextPrevious(0,0)<CR>
|
||||||
|
xnoremap <silent><Plug>(easymotion-next)
|
||||||
|
\ <Esc>:<C-u>call EasyMotion#NextPrevious(1,0)<CR>
|
||||||
|
|
||||||
|
noremap <silent><Plug>(easymotion-previous)
|
||||||
|
\ :<C-u>call EasyMotion#NextPrevious(0,1)<CR>
|
||||||
|
xnoremap <silent><Plug>(easymotion-previous)
|
||||||
|
\ <Esc>:<C-u>call EasyMotion#NextPrevious(1,1)<CR>
|
||||||
|
"}}}
|
||||||
|
|
||||||
" -- Line Motion {{{
|
" -- Line Motion {{{
|
||||||
" Word Line: {{{
|
" Word Line: {{{
|
||||||
noremap <silent><Plug>(easymotion-wl) :<C-u>call EasyMotion#WBL(0,0)<CR>
|
noremap <silent><Plug>(easymotion-wl) :<C-u>call EasyMotion#WBL(0,0)<CR>
|
||||||
|
@ -291,6 +291,22 @@ describe 'Default settings'
|
|||||||
\ ==# '<Esc>:<C-U>call EasyMotion#DotRepeat(1)<CR>'
|
\ ==# '<Esc>:<C-U>call EasyMotion#DotRepeat(1)<CR>'
|
||||||
" }}}
|
" }}}
|
||||||
|
|
||||||
|
" Next, Previous motion {{{
|
||||||
|
Expect maparg('<Plug>(easymotion-next)', 'n')
|
||||||
|
\ ==# ':<C-U>call EasyMotion#NextPrevious(0,0)<CR>'
|
||||||
|
Expect maparg('<Plug>(easymotion-next)', 'o')
|
||||||
|
\ ==# ':<C-U>call EasyMotion#NextPrevious(0,0)<CR>'
|
||||||
|
Expect maparg('<Plug>(easymotion-next)', 'v')
|
||||||
|
\ ==# '<Esc>:<C-U>call EasyMotion#NextPrevious(1,0)<CR>'
|
||||||
|
|
||||||
|
Expect maparg('<Plug>(easymotion-previous)', 'n')
|
||||||
|
\ ==# ':<C-U>call EasyMotion#NextPrevious(0,1)<CR>'
|
||||||
|
Expect maparg('<Plug>(easymotion-previous)', 'o')
|
||||||
|
\ ==# ':<C-U>call EasyMotion#NextPrevious(0,1)<CR>'
|
||||||
|
Expect maparg('<Plug>(easymotion-previous)', 'v')
|
||||||
|
\ ==# '<Esc>:<C-U>call EasyMotion#NextPrevious(1,1)<CR>'
|
||||||
|
" }}}
|
||||||
|
|
||||||
" Line Motion: {{{
|
" Line Motion: {{{
|
||||||
" word
|
" word
|
||||||
Expect maparg('<Plug>(easymotion-wl)', 'n') ==# ':<C-U>call EasyMotion#WBL(0,0)<CR>'
|
Expect maparg('<Plug>(easymotion-wl)', 'n') ==# ':<C-U>call EasyMotion#WBL(0,0)<CR>'
|
||||||
@ -390,6 +406,7 @@ describe 'Default settings'
|
|||||||
Expect exists('*EasyMotion#SelectPhraseYank') ==# 1
|
Expect exists('*EasyMotion#SelectPhraseYank') ==# 1
|
||||||
Expect exists('*EasyMotion#SelectPhraseDelete') ==# 1
|
Expect exists('*EasyMotion#SelectPhraseDelete') ==# 1
|
||||||
Expect exists('*EasyMotion#Repeat') ==# 1
|
Expect exists('*EasyMotion#Repeat') ==# 1
|
||||||
|
Expect exists('*EasyMotion#NextPrevious') ==# 1
|
||||||
Expect exists('*EasyMotion#DotRepeat') ==# 1
|
Expect exists('*EasyMotion#DotRepeat') ==# 1
|
||||||
"}}}
|
"}}}
|
||||||
end
|
end
|
||||||
@ -946,3 +963,83 @@ describe 'g:EasyMotion_smartsign'
|
|||||||
" }}}
|
" }}}
|
||||||
end
|
end
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
" Next & Previous {{{
|
||||||
|
describe '<Plug>(easymotion-next) & <Plug>(easymotion-previous)'
|
||||||
|
before
|
||||||
|
new
|
||||||
|
let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
|
map s <Plug>(easymotion-s)
|
||||||
|
map ; <Plug>(easymotion-next)
|
||||||
|
map , <Plug>(easymotion-previous)
|
||||||
|
set wrapscan
|
||||||
|
call EasyMotion#init()
|
||||||
|
call AddLine('poge huga hiyo poyo')
|
||||||
|
" 1234567890123456789
|
||||||
|
end
|
||||||
|
|
||||||
|
after
|
||||||
|
close!
|
||||||
|
end
|
||||||
|
|
||||||
|
" provide next & previous motion to replace `;`, `,` {{{
|
||||||
|
it 'provide next & previous motion to replace `;`, `,`'
|
||||||
|
normal! 0
|
||||||
|
let l = line('.')
|
||||||
|
Expect CursorPos() == [l,1,'p']
|
||||||
|
normal sha
|
||||||
|
Expect CursorPos() == [l,6,'h']
|
||||||
|
|
||||||
|
normal ;
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
|
||||||
|
normal ,
|
||||||
|
Expect CursorPos() == [l,6,'h']
|
||||||
|
|
||||||
|
" wrapscan
|
||||||
|
normal ,
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
normal ;
|
||||||
|
Expect CursorPos() == [l,6,'h']
|
||||||
|
|
||||||
|
normal! $
|
||||||
|
let l = line('.')
|
||||||
|
Expect CursorPos() == [l,19,'o']
|
||||||
|
|
||||||
|
normal ,
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
|
||||||
|
end
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" next & previous motion count {{{
|
||||||
|
it 'next & previous motion count'
|
||||||
|
normal! 0
|
||||||
|
let l = line('.')
|
||||||
|
Expect CursorPos() == [l,1,'p']
|
||||||
|
normal sha
|
||||||
|
Expect CursorPos() == [l,6,'h']
|
||||||
|
|
||||||
|
normal ;
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
|
||||||
|
normal 2,
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
|
||||||
|
" wrapscan
|
||||||
|
normal 4,
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
normal 3;
|
||||||
|
Expect CursorPos() == [l,6,'h']
|
||||||
|
|
||||||
|
normal! $
|
||||||
|
let l = line('.')
|
||||||
|
Expect CursorPos() == [l,19,'o']
|
||||||
|
|
||||||
|
normal ,
|
||||||
|
Expect CursorPos() == [l,11,'h']
|
||||||
|
|
||||||
|
end
|
||||||
|
"}}}
|
||||||
|
end
|
||||||
|
"}}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user