diff --git a/doc/easymotion.txt b/doc/easymotion.txt index ce36a18..a7bae08 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -1,4 +1,4 @@ -*easymotion.txt* Version 1.0.12. Last change: 2011 Mar 31 +*easymotion.txt* Version 1.1. Last change: 2011 Mar 31 ______ __ ___ __ _ @@ -72,8 +72,8 @@ And that's it! ------------------------------------------------------------------------------ 2.1 Default mappings *easymotion-default-mappings* -The default configuration provides the following mappings in both normal and -visual mode: +The default configuration defines the following mappings in normal, +visual and operator-pending mode: Mapping | Details ------------------|---------------------------------------------- @@ -190,6 +190,7 @@ Source repository: https://github.com/Lokaltog/vim-easymotion 8. Credits *easymotion-credits* - Ben Boeckel: ge motion +- Drew Neil: operator-pending mappings EasyMotion is based on Bartlomiej Podolak's great PreciseJump script, which can be downloaded here: diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 747087e..bcfd584 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -60,33 +60,43 @@ " Default key mapping {{{ if g:EasyMotion_do_mapping nnoremap f :call EasyMotionF(0, 0) + onoremap f :call EasyMotionF(0, 0) vnoremap f :call EasyMotionF(1, 0) nnoremap F :call EasyMotionF(0, 1) + onoremap F :call EasyMotionF(0, 1) vnoremap F :call EasyMotionF(1, 1) nnoremap t :call EasyMotionT(0, 0) + onoremap t :call EasyMotionT(0, 0) vnoremap t :call EasyMotionT(1, 0) nnoremap T :call EasyMotionT(0, 1) + onoremap T :call EasyMotionT(0, 1) vnoremap T :call EasyMotionT(1, 1) nnoremap w :call EasyMotionWB(0, 0) + onoremap w :call EasyMotionWB(0, 0) vnoremap w :call EasyMotionWB(1, 0) nnoremap b :call EasyMotionWB(0, 1) + onoremap b :call EasyMotionWB(0, 1) vnoremap b :call EasyMotionWB(1, 1) nnoremap e :call EasyMotionE(0, 0) + onoremap e :call EasyMotionE(0, 0) vnoremap e :call EasyMotionE(1, 0) nnoremap ge :call EasyMotionE(0, 1) + onoremap ge :call EasyMotionE(0, 1) vnoremap ge :call EasyMotionE(1, 1) nnoremap j :call EasyMotionJK(0, 0) + onoremap j :call EasyMotionJK(0, 0) vnoremap j :call EasyMotionJK(1, 0) nnoremap k :call EasyMotionJK(0, 1) + onoremap k :call EasyMotionJK(0, 1) vnoremap k :call EasyMotionJK(1, 1) endif " }}} @@ -107,7 +117,6 @@ endfunction "}}} let [s:index_to_key, s:key_to_index] = s:CreateIndex(g:EasyMotion_keys) - let s:var_reset = {} " }}} " Motion functions {{{ function! EasyMotionF(visualmode, direction) " {{{ @@ -119,7 +128,7 @@ let re = '\C' . escape(char, '.$^~') - call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '') + call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1)) endfunction " }}} function! EasyMotionT(visualmode, direction) " {{{ let char = s:GetSearchChar(a:visualmode) @@ -134,16 +143,16 @@ let re = '\C.' . escape(char, '.$^~') endif - call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '') + call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1)) endfunction " }}} function! EasyMotionWB(visualmode, direction) " {{{ - call s:EasyMotion('\<.', a:direction, a:visualmode ? visualmode() : '') + call s:EasyMotion('\<.', a:direction, a:visualmode ? visualmode() : '', mode(1)) endfunction " }}} function! EasyMotionE(visualmode, direction) " {{{ - call s:EasyMotion('.\>', a:direction, a:visualmode ? visualmode() : '') + call s:EasyMotion('.\>', a:direction, a:visualmode ? visualmode() : '', mode(1)) endfunction " }}} function! EasyMotionJK(visualmode, direction) " {{{ - call s:EasyMotion('\%1v', a:direction, a:visualmode ? visualmode() : '') + call s:EasyMotion('\%1v', a:direction, a:visualmode ? visualmode() : '', mode(1)) endfunction " }}} " }}} " Helper functions {{{ @@ -156,6 +165,10 @@ echohl None endfunction " }}} function! s:VarReset(var, ...) " {{{ + if ! exists('s:var_reset') + let s:var_reset = {} + endif + let buf = bufname("") if a:0 == 0 && has_key(s:var_reset, a:var) @@ -311,7 +324,7 @@ return s:PromptUser([a:groups[s:key_to_index[char]]]) endif endfunction "}}} - function! s:EasyMotion(regexp, direction, visualmode) " {{{ + function! s:EasyMotion(regexp, direction, visualmode, mode) " {{{ let orig_pos = [line('.'), col('.')] let targets = [] @@ -392,6 +405,17 @@ exec 'normal! ' . a:visualmode endif + if a:mode == 'no' + " Operator-pending mode + " + " This mode requires that we eat one more + " character to the right if we're using + " a forward motion + if a:direction != 1 + let coords[1] += 1 + endif + endif + " Update cursor position call cursor(coords[0], coords[1])