diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 389b1db..27bac01 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -215,9 +215,12 @@ function! EasyMotion#Eol(visualmode, direction) " {{{ return s:EasyMotion_is_cancelled endfunction " }}} " -- Search Motion ----------------------- -function! EasyMotion#Search(visualmode, direction) " {{{ +function! EasyMotion#Search(visualmode, direction, respect_direction) " {{{ 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 endfunction " }}} " -- JumpToAnywhere Motion --------------- diff --git a/doc/easymotion.txt b/doc/easymotion.txt index 828b528..3c7d6fb 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -163,6 +163,8 @@ EasyMotion table *easymotion-plug-table* (easymotion-iskeyword-e) | See |(easymotion-iskeyword-e)| (easymotion-iskeyword-ge) | See |(easymotion-iskeyword-ge)| (easymotion-iskeyword-bd-e) | See |(easymotion-iskeyword-bd-e)| + (easymotion-vim-n) | See |(easymotion-vim-n)| + (easymotion-vim-N) | See |(easymotion-vim-N)| | Within Line Motion | See |easymotion-within-line| ----------------------------------|--------------------------------- @@ -391,6 +393,15 @@ iskeyword compatible word motions *(easymotion-iskeyword-w)* < NOTE: Within line motions are compatible with |iskeyword| by default. +Search motion respect previous direction + + (easymotion-vim-n) *(easymotion-vim-n)* + (easymotion-vim-N) *(easymotion-vim-N)* + + This is vim compatible |n| & |N| easymotion. Unlike |(easymotion-n)| + and |(easymotion-N)| 's direction is always forward or backward, + these motions consider previous search direction. + Within line motion ~ *easymotion-within-line* diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 506fb86..c5931cd 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -206,12 +206,18 @@ xnoremap (easymotion-eol-bd-jk) :call EasyMotion#Eol(1,2 "}}} " -- Search Motion {{{ -noremap (easymotion-n) :call EasyMotion#Search(0,0) -xnoremap (easymotion-n) :call EasyMotion#Search(1,0) -noremap (easymotion-N) :call EasyMotion#Search(0,1) -xnoremap (easymotion-N) :call EasyMotion#Search(1,1) -noremap (easymotion-bd-n) :call EasyMotion#Search(0,2) -xnoremap (easymotion-bd-n) :call EasyMotion#Search(1,2) +noremap (easymotion-n) :call EasyMotion#Search(0,0,0) +xnoremap (easymotion-n) :call EasyMotion#Search(1,0,0) +noremap (easymotion-N) :call EasyMotion#Search(0,1,0) +xnoremap (easymotion-N) :call EasyMotion#Search(1,1,0) + +noremap (easymotion-vim-n) :call EasyMotion#Search(0,0,1) +xnoremap (easymotion-vim-n) :call EasyMotion#Search(1,0,1) +noremap (easymotion-vim-N) :call EasyMotion#Search(0,1,1) +xnoremap (easymotion-vim-N) :call EasyMotion#Search(1,1,1) + +noremap (easymotion-bd-n) :call EasyMotion#Search(0,2,0) +xnoremap (easymotion-bd-n) :call EasyMotion#Search(1,2,0) "}}} " -- Jump To Anywhere Motion {{{ diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index ae2895b..bc44517 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -330,15 +330,23 @@ describe 'Default settings' " }}} " Search Motion: {{{ - Expect maparg('(easymotion-n)', 'n') ==# ':call EasyMotion#Search(0,0)' - Expect maparg('(easymotion-n)', 'o') ==# ':call EasyMotion#Search(0,0)' - Expect maparg('(easymotion-n)', 'v') ==# ':call EasyMotion#Search(1,0)' - Expect maparg('(easymotion-N)', 'n') ==# ':call EasyMotion#Search(0,1)' - Expect maparg('(easymotion-N)', 'o') ==# ':call EasyMotion#Search(0,1)' - Expect maparg('(easymotion-N)', 'v') ==# ':call EasyMotion#Search(1,1)' - Expect maparg('(easymotion-bd-n)', 'n') ==# ':call EasyMotion#Search(0,2)' - Expect maparg('(easymotion-bd-n)', 'o') ==# ':call EasyMotion#Search(0,2)' - Expect maparg('(easymotion-bd-n)', 'v') ==# ':call EasyMotion#Search(1,2)' + Expect maparg('(easymotion-n)', 'n') ==# ':call EasyMotion#Search(0,0,0)' + Expect maparg('(easymotion-n)', 'o') ==# ':call EasyMotion#Search(0,0,0)' + Expect maparg('(easymotion-n)', 'v') ==# ':call EasyMotion#Search(1,0,0)' + Expect maparg('(easymotion-N)', 'n') ==# ':call EasyMotion#Search(0,1,0)' + Expect maparg('(easymotion-N)', 'o') ==# ':call EasyMotion#Search(0,1,0)' + Expect maparg('(easymotion-N)', 'v') ==# ':call EasyMotion#Search(1,1,0)' + Expect maparg('(easymotion-bd-n)', 'n') ==# ':call EasyMotion#Search(0,2,0)' + Expect maparg('(easymotion-bd-n)', 'o') ==# ':call EasyMotion#Search(0,2,0)' + Expect maparg('(easymotion-bd-n)', 'v') ==# ':call EasyMotion#Search(1,2,0)' + + " respect previous direction + Expect maparg('(easymotion-vim-n)', 'n') ==# ':call EasyMotion#Search(0,0,1)' + Expect maparg('(easymotion-vim-n)', 'o') ==# ':call EasyMotion#Search(0,0,1)' + Expect maparg('(easymotion-vim-n)', 'v') ==# ':call EasyMotion#Search(1,0,1)' + Expect maparg('(easymotion-vim-N)', 'n') ==# ':call EasyMotion#Search(0,1,1)' + Expect maparg('(easymotion-vim-N)', 'o') ==# ':call EasyMotion#Search(0,1,1)' + Expect maparg('(easymotion-vim-N)', 'v') ==# ':call EasyMotion#Search(1,1,1)' " }}} " JumpToAnywhere Motion: {{{