Merge branch 'add-respect-n-N'

This commit is contained in:
haya14busa 2014-06-28 17:22:46 +09:00
commit ff793c6629
4 changed files with 45 additions and 17 deletions

View File

@ -215,9 +215,12 @@ function! EasyMotion#Eol(visualmode, direction) " {{{
return s:EasyMotion_is_cancelled return s:EasyMotion_is_cancelled
endfunction " }}} endfunction " }}}
" -- Search Motion ----------------------- " -- Search Motion -----------------------
function! EasyMotion#Search(visualmode, direction) " {{{ function! EasyMotion#Search(visualmode, direction, respect_direction) " {{{
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', 0) let search_direction = a:respect_direction ?
\ (a:direction == 1 ? v:searchforward : 1-v:searchforward) :
\ (a:direction)
call s:EasyMotion(@/, search_direction, a:visualmode ? visualmode() : '', 0)
return s:EasyMotion_is_cancelled return s:EasyMotion_is_cancelled
endfunction " }}} endfunction " }}}
" -- JumpToAnywhere Motion --------------- " -- JumpToAnywhere Motion ---------------

View File

@ -163,6 +163,8 @@ EasyMotion <Plug> table *easymotion-plug-table*
<Plug>(easymotion-iskeyword-e) | See |<Plug>(easymotion-iskeyword-e)| <Plug>(easymotion-iskeyword-e) | See |<Plug>(easymotion-iskeyword-e)|
<Plug>(easymotion-iskeyword-ge) | See |<Plug>(easymotion-iskeyword-ge)| <Plug>(easymotion-iskeyword-ge) | See |<Plug>(easymotion-iskeyword-ge)|
<Plug>(easymotion-iskeyword-bd-e) | See |<Plug>(easymotion-iskeyword-bd-e)| <Plug>(easymotion-iskeyword-bd-e) | See |<Plug>(easymotion-iskeyword-bd-e)|
<Plug>(easymotion-vim-n) | See |<Plug>(easymotion-vim-n)|
<Plug>(easymotion-vim-N) | See |<Plug>(easymotion-vim-N)|
| |
Within Line Motion | See |easymotion-within-line| Within Line Motion | See |easymotion-within-line|
----------------------------------|--------------------------------- ----------------------------------|---------------------------------
@ -391,6 +393,15 @@ iskeyword compatible word motions *<Plug>(easymotion-iskeyword-w)*
< <
NOTE: Within line motions are compatible with |iskeyword| by default. NOTE: Within line motions are compatible with |iskeyword| by default.
Search motion respect previous direction
<Plug>(easymotion-vim-n) *<Plug>(easymotion-vim-n)*
<Plug>(easymotion-vim-N) *<Plug>(easymotion-vim-N)*
This is vim compatible |n| & |N| easymotion. Unlike |<Plug>(easymotion-n)|
and |<Plug>(easymotion-N)| 's direction is always forward or backward,
these motions consider previous search direction.
Within line motion ~ Within line motion ~
*easymotion-within-line* *easymotion-within-line*

View File

@ -206,12 +206,18 @@ xnoremap <silent><Plug>(easymotion-eol-bd-jk) <Esc>:<C-u>call EasyMotion#Eol(1,2
"}}} "}}}
" -- Search Motion {{{ " -- Search Motion {{{
noremap <silent><Plug>(easymotion-n) :<C-u>call EasyMotion#Search(0,0)<CR> noremap <silent><Plug>(easymotion-n) :<C-u>call EasyMotion#Search(0,0,0)<CR>
xnoremap <silent><Plug>(easymotion-n) <Esc>:<C-u>call EasyMotion#Search(1,0)<CR> xnoremap <silent><Plug>(easymotion-n) <Esc>:<C-u>call EasyMotion#Search(1,0,0)<CR>
noremap <silent><Plug>(easymotion-N) :<C-u>call EasyMotion#Search(0,1)<CR> noremap <silent><Plug>(easymotion-N) :<C-u>call EasyMotion#Search(0,1,0)<CR>
xnoremap <silent><Plug>(easymotion-N) <Esc>:<C-u>call EasyMotion#Search(1,1)<CR> xnoremap <silent><Plug>(easymotion-N) <Esc>:<C-u>call EasyMotion#Search(1,1,0)<CR>
noremap <silent><Plug>(easymotion-bd-n) :<C-u>call EasyMotion#Search(0,2)<CR>
xnoremap <silent><Plug>(easymotion-bd-n) <Esc>:<C-u>call EasyMotion#Search(1,2)<CR> noremap <silent><Plug>(easymotion-vim-n) :<C-u>call EasyMotion#Search(0,0,1)<CR>
xnoremap <silent><Plug>(easymotion-vim-n) <Esc>:<C-u>call EasyMotion#Search(1,0,1)<CR>
noremap <silent><Plug>(easymotion-vim-N) :<C-u>call EasyMotion#Search(0,1,1)<CR>
xnoremap <silent><Plug>(easymotion-vim-N) <Esc>:<C-u>call EasyMotion#Search(1,1,1)<CR>
noremap <silent><Plug>(easymotion-bd-n) :<C-u>call EasyMotion#Search(0,2,0)<CR>
xnoremap <silent><Plug>(easymotion-bd-n) <Esc>:<C-u>call EasyMotion#Search(1,2,0)<CR>
"}}} "}}}
" -- Jump To Anywhere Motion {{{ " -- Jump To Anywhere Motion {{{

View File

@ -330,15 +330,23 @@ describe 'Default settings'
" }}} " }}}
" Search Motion: {{{ " Search Motion: {{{
Expect maparg('<Plug>(easymotion-n)', 'n') ==# ':<C-U>call EasyMotion#Search(0,0)<CR>' Expect maparg('<Plug>(easymotion-n)', 'n') ==# ':<C-U>call EasyMotion#Search(0,0,0)<CR>'
Expect maparg('<Plug>(easymotion-n)', 'o') ==# ':<C-U>call EasyMotion#Search(0,0)<CR>' Expect maparg('<Plug>(easymotion-n)', 'o') ==# ':<C-U>call EasyMotion#Search(0,0,0)<CR>'
Expect maparg('<Plug>(easymotion-n)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,0)<CR>' Expect maparg('<Plug>(easymotion-n)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,0,0)<CR>'
Expect maparg('<Plug>(easymotion-N)', 'n') ==# ':<C-U>call EasyMotion#Search(0,1)<CR>' Expect maparg('<Plug>(easymotion-N)', 'n') ==# ':<C-U>call EasyMotion#Search(0,1,0)<CR>'
Expect maparg('<Plug>(easymotion-N)', 'o') ==# ':<C-U>call EasyMotion#Search(0,1)<CR>' Expect maparg('<Plug>(easymotion-N)', 'o') ==# ':<C-U>call EasyMotion#Search(0,1,0)<CR>'
Expect maparg('<Plug>(easymotion-N)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,1)<CR>' Expect maparg('<Plug>(easymotion-N)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,1,0)<CR>'
Expect maparg('<Plug>(easymotion-bd-n)', 'n') ==# ':<C-U>call EasyMotion#Search(0,2)<CR>' Expect maparg('<Plug>(easymotion-bd-n)', 'n') ==# ':<C-U>call EasyMotion#Search(0,2,0)<CR>'
Expect maparg('<Plug>(easymotion-bd-n)', 'o') ==# ':<C-U>call EasyMotion#Search(0,2)<CR>' Expect maparg('<Plug>(easymotion-bd-n)', 'o') ==# ':<C-U>call EasyMotion#Search(0,2,0)<CR>'
Expect maparg('<Plug>(easymotion-bd-n)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,2)<CR>' Expect maparg('<Plug>(easymotion-bd-n)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,2,0)<CR>'
" respect previous direction
Expect maparg('<Plug>(easymotion-vim-n)', 'n') ==# ':<C-U>call EasyMotion#Search(0,0,1)<CR>'
Expect maparg('<Plug>(easymotion-vim-n)', 'o') ==# ':<C-U>call EasyMotion#Search(0,0,1)<CR>'
Expect maparg('<Plug>(easymotion-vim-n)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-vim-N)', 'n') ==# ':<C-U>call EasyMotion#Search(0,1,1)<CR>'
Expect maparg('<Plug>(easymotion-vim-N)', 'o') ==# ':<C-U>call EasyMotion#Search(0,1,1)<CR>'
Expect maparg('<Plug>(easymotion-vim-N)', 'v') ==# '<Esc>:<C-U>call EasyMotion#Search(1,1,1)<CR>'
" }}} " }}}
" JumpToAnywhere Motion: {{{ " JumpToAnywhere Motion: {{{