Merge branch 'feature/next-previous' into master

This commit is contained in:
haya14busa 2014-01-16 23:20:42 +09:00
commit 7c2ed49d3a
4 changed files with 147 additions and 9 deletions

View File

@ -413,6 +413,20 @@ function! EasyMotion#DotRepeat(visualmode) " {{{
silent call s:EasyMotion(re, direction, 0, is_exclusive)
endfor
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 {{{
" -- Message -----------------------------

View File

@ -151,6 +151,8 @@ EasyMotion <Plug> table *easymotion-plug-table*
<Plug>(easymotion-bd-n) | See |<Plug>(easymotion-bd-n)|
<Plug>(easymotion-jumptoanywhere) | See |<Plug>(easymotion-jumptoanywhere)|
<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-eol-j) | See |<Plug>(easymotion-eol-j)|
|
@ -244,17 +246,30 @@ Jump To Anywhere ~
Repeat ~
<Plug>(easymotion-repeat) *<Plug>(easymotion-repeat)*
Repeat last motion!
Repeat last motion!
Repeat last motion type including input target character.
Nothing will happen when previous motion doesn't exist.
Repeat last motion type including input target character.
Nothing will happen when previous motion doesn't exist.
Last Find Motion~
In Find motion (e.g. |<Plug>(easymoion-s)| ), to type `<CR>`
without input characters invoke last find motion. This
does not repeat motion type (e.g. othrer word motion,
<Plug>(easymotion-j) etc...) but only repeat input
characters.
Last Find Motion~
In Find motion (e.g. |<Plug>(easymoion-s)| ), to type `<CR>`
without input characters invoke last find motion. This
does not repeat motion type (e.g. othrer word motion,
<Plug>(easymotion-j) etc...) but only repeat input
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-dotrepeat* *easymotion-textobjct*

View File

@ -250,6 +250,18 @@ xnoremap <silent><Plug>(easymotion-dotrepeat)
\ <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 {{{
" Word Line: {{{
noremap <silent><Plug>(easymotion-wl) :<C-u>call EasyMotion#WBL(0,0)<CR>

View File

@ -291,6 +291,22 @@ describe 'Default settings'
\ ==# '<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: {{{
" word
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#SelectPhraseDelete') ==# 1
Expect exists('*EasyMotion#Repeat') ==# 1
Expect exists('*EasyMotion#NextPrevious') ==# 1
Expect exists('*EasyMotion#DotRepeat') ==# 1
"}}}
end
@ -946,3 +963,83 @@ describe 'g:EasyMotion_smartsign'
" }}}
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
"}}}