Add character . for repeating line for selectlines()

This commit is contained in:
Supasorn Suwajanakorn 2013-05-23 01:02:03 -07:00
parent f2f6e4e72e
commit 3ede0e986c

View File

@ -61,20 +61,26 @@
" Motion functions {{{ " Motion functions {{{
function! EasyMotion#SelectLines() function! EasyMotion#SelectLines()
let orig_pos = [line('.'), col('.')] let orig_pos = [line('.'), col('.')]
let g:wait_for_repeat = 0
call EasyMotion#JK(0, 2) call EasyMotion#JK(0, 2)
if g:EasyMotion_cancelled if g:EasyMotion_cancelled
return '' return ''
else else
let pos1 = [line('.'), col('.')] let pos1 = [line('.'), col('.')]
keepjumps call cursor(orig_pos[0], orig_pos[1]) keepjumps call cursor(orig_pos[0], orig_pos[1])
let g:wait_for_repeat = 1
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', pos1[0]) call s:EasyMotion('^\(\w\|\s*\zs\|$\)', 2, '', '', pos1[0])
if g:EasyMotion_cancelled if g:EasyMotion_cancelled
return '' return ''
elseif g:wait_for_repeat == 2 " User pressed '.'
keepjumps call cursor(pos1[0], pos1[1])
"normal! V
else else
normal! V normal! V
keepjumps call cursor(pos1[0], pos1[1]) keepjumps call cursor(pos1[0], pos1[1])
endif endif
endif endif
let g:wait_for_repeat = 0
endfunction endfunction
function! EasyMotion#F(visualmode, direction) " {{{ function! EasyMotion#F(visualmode, direction) " {{{
let char = s:GetSearchChar(a:visualmode) let char = s:GetSearchChar(a:visualmode)
@ -508,6 +514,9 @@
endif endif
" }}} " }}}
" Check if the input char is valid {{{ " Check if the input char is valid {{{
if g:wait_for_repeat && char == '.'
return g:old_target
else
if ! has_key(a:groups, char) if ! has_key(a:groups, char)
throw 'Invalid target' throw 'Invalid target'
endif endif
@ -522,6 +531,7 @@
" Prompt for new target character " Prompt for new target character
return s:PromptUser(target) return s:PromptUser(target)
endif endif
endif
endfunction "}}} endfunction "}}}
function! s:EasyMotion(regexp, direction, visualmode, mode, hlcurrent) " {{{ function! s:EasyMotion(regexp, direction, visualmode, mode, hlcurrent) " {{{
let orig_pos = [line('.'), col('.')] let orig_pos = [line('.'), col('.')]
@ -621,6 +631,7 @@
" Prompt user for target group/character " Prompt user for target group/character
let coords = s:PromptUser(groups) let coords = s:PromptUser(groups)
let g:old_target = coords
" Update selection {{{ " Update selection {{{
if ! empty(a:visualmode) if ! empty(a:visualmode)