Merge branch 'feature/7-operator-pending-mode' into develop
* feature/7-operator-pending-mode: Update credits Eat one extra char if in operator-pending mode Add mappings for operator pending mode. Closes #7.
This commit is contained in:
commit
b8cdeedac3
@ -190,6 +190,7 @@ Source repository: https://github.com/Lokaltog/vim-easymotion
|
|||||||
8. Credits *easymotion-credits*
|
8. Credits *easymotion-credits*
|
||||||
|
|
||||||
- Ben Boeckel: ge motion
|
- Ben Boeckel: ge motion
|
||||||
|
- Drew Neil: operator-pending mappings
|
||||||
|
|
||||||
EasyMotion is based on Bartlomiej Podolak's great PreciseJump script, which
|
EasyMotion is based on Bartlomiej Podolak's great PreciseJump script, which
|
||||||
can be downloaded here:
|
can be downloaded here:
|
||||||
|
@ -60,33 +60,43 @@
|
|||||||
" Default key mapping {{{
|
" Default key mapping {{{
|
||||||
if g:EasyMotion_do_mapping
|
if g:EasyMotion_do_mapping
|
||||||
nnoremap <silent> <Leader>f :call EasyMotionF(0, 0)<CR>
|
nnoremap <silent> <Leader>f :call EasyMotionF(0, 0)<CR>
|
||||||
|
onoremap <silent> <Leader>f :call EasyMotionF(0, 0)<CR>
|
||||||
vnoremap <silent> <Leader>f :<C-U>call EasyMotionF(1, 0)<CR>
|
vnoremap <silent> <Leader>f :<C-U>call EasyMotionF(1, 0)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>F :call EasyMotionF(0, 1)<CR>
|
nnoremap <silent> <Leader>F :call EasyMotionF(0, 1)<CR>
|
||||||
|
onoremap <silent> <Leader>F :call EasyMotionF(0, 1)<CR>
|
||||||
vnoremap <silent> <Leader>F :<C-U>call EasyMotionF(1, 1)<CR>
|
vnoremap <silent> <Leader>F :<C-U>call EasyMotionF(1, 1)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>t :call EasyMotionT(0, 0)<CR>
|
nnoremap <silent> <Leader>t :call EasyMotionT(0, 0)<CR>
|
||||||
|
onoremap <silent> <Leader>t :call EasyMotionT(0, 0)<CR>
|
||||||
vnoremap <silent> <Leader>t :<C-U>call EasyMotionT(1, 0)<CR>
|
vnoremap <silent> <Leader>t :<C-U>call EasyMotionT(1, 0)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>T :call EasyMotionT(0, 1)<CR>
|
nnoremap <silent> <Leader>T :call EasyMotionT(0, 1)<CR>
|
||||||
|
onoremap <silent> <Leader>T :call EasyMotionT(0, 1)<CR>
|
||||||
vnoremap <silent> <Leader>T :<C-U>call EasyMotionT(1, 1)<CR>
|
vnoremap <silent> <Leader>T :<C-U>call EasyMotionT(1, 1)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>w :call EasyMotionWB(0, 0)<CR>
|
nnoremap <silent> <Leader>w :call EasyMotionWB(0, 0)<CR>
|
||||||
|
onoremap <silent> <Leader>w :call EasyMotionWB(0, 0)<CR>
|
||||||
vnoremap <silent> <Leader>w :<C-U>call EasyMotionWB(1, 0)<CR>
|
vnoremap <silent> <Leader>w :<C-U>call EasyMotionWB(1, 0)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>b :call EasyMotionWB(0, 1)<CR>
|
nnoremap <silent> <Leader>b :call EasyMotionWB(0, 1)<CR>
|
||||||
|
onoremap <silent> <Leader>b :call EasyMotionWB(0, 1)<CR>
|
||||||
vnoremap <silent> <Leader>b :<C-U>call EasyMotionWB(1, 1)<CR>
|
vnoremap <silent> <Leader>b :<C-U>call EasyMotionWB(1, 1)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>e :call EasyMotionE(0, 0)<CR>
|
nnoremap <silent> <Leader>e :call EasyMotionE(0, 0)<CR>
|
||||||
|
onoremap <silent> <Leader>e :call EasyMotionE(0, 0)<CR>
|
||||||
vnoremap <silent> <Leader>e :<C-U>call EasyMotionE(1, 0)<CR>
|
vnoremap <silent> <Leader>e :<C-U>call EasyMotionE(1, 0)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>ge :call EasyMotionE(0, 1)<CR>
|
nnoremap <silent> <Leader>ge :call EasyMotionE(0, 1)<CR>
|
||||||
|
onoremap <silent> <Leader>ge :call EasyMotionE(0, 1)<CR>
|
||||||
vnoremap <silent> <Leader>ge :<C-U>call EasyMotionE(1, 1)<CR>
|
vnoremap <silent> <Leader>ge :<C-U>call EasyMotionE(1, 1)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>j :call EasyMotionJK(0, 0)<CR>
|
nnoremap <silent> <Leader>j :call EasyMotionJK(0, 0)<CR>
|
||||||
|
onoremap <silent> <Leader>j :call EasyMotionJK(0, 0)<CR>
|
||||||
vnoremap <silent> <Leader>j :<C-U>call EasyMotionJK(1, 0)<CR>
|
vnoremap <silent> <Leader>j :<C-U>call EasyMotionJK(1, 0)<CR>
|
||||||
|
|
||||||
nnoremap <silent> <Leader>k :call EasyMotionJK(0, 1)<CR>
|
nnoremap <silent> <Leader>k :call EasyMotionJK(0, 1)<CR>
|
||||||
|
onoremap <silent> <Leader>k :call EasyMotionJK(0, 1)<CR>
|
||||||
vnoremap <silent> <Leader>k :<C-U>call EasyMotionJK(1, 1)<CR>
|
vnoremap <silent> <Leader>k :<C-U>call EasyMotionJK(1, 1)<CR>
|
||||||
endif
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
@ -118,7 +128,7 @@
|
|||||||
|
|
||||||
let re = '\C' . escape(char, '.$^~')
|
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 " }}}
|
endfunction " }}}
|
||||||
function! EasyMotionT(visualmode, direction) " {{{
|
function! EasyMotionT(visualmode, direction) " {{{
|
||||||
let char = s:GetSearchChar(a:visualmode)
|
let char = s:GetSearchChar(a:visualmode)
|
||||||
@ -133,16 +143,16 @@
|
|||||||
let re = '\C.' . escape(char, '.$^~')
|
let re = '\C.' . escape(char, '.$^~')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '')
|
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', mode(1))
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotionWB(visualmode, direction) " {{{
|
function! EasyMotionWB(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('\<.', a:direction, a:visualmode ? visualmode() : '')
|
call s:EasyMotion('\<.', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotionE(visualmode, direction) " {{{
|
function! EasyMotionE(visualmode, direction) " {{{
|
||||||
call s:EasyMotion('.\>', a:direction, a:visualmode ? visualmode() : '')
|
call s:EasyMotion('.\>', a:direction, a:visualmode ? visualmode() : '', mode(1))
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! EasyMotionJK(visualmode, direction) " {{{
|
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 " }}}
|
endfunction " }}}
|
||||||
" }}}
|
" }}}
|
||||||
" Helper functions {{{
|
" Helper functions {{{
|
||||||
@ -314,7 +324,7 @@
|
|||||||
return s:PromptUser([a:groups[s:key_to_index[char]]])
|
return s:PromptUser([a:groups[s:key_to_index[char]]])
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:EasyMotion(regexp, direction, visualmode) " {{{
|
function! s:EasyMotion(regexp, direction, visualmode, mode) " {{{
|
||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
let targets = []
|
let targets = []
|
||||||
|
|
||||||
@ -395,6 +405,17 @@
|
|||||||
exec 'normal! ' . a:visualmode
|
exec 'normal! ' . a:visualmode
|
||||||
endif
|
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
|
" Update cursor position
|
||||||
call cursor(coords[0], coords[1])
|
call cursor(coords[0], coords[1])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user