On Oct 15, 2:07 pm, Ben Fritz <[email protected]> wrote:
> On Oct 14, 4:33 am, Sergii Boiko <[email protected]> wrote:
>
> > Ingo, thanks for positive comment. Because i'm switching to dvorak and
> > 'f' isn't so useful at this layout as 't'. And this behaviour very
> > annoys me, because 't' is not so handy as 'f'.
>
> > I don't know vim-script very well to write some prototype, but if
> > someone takes care of it, i will test it thoroughly.
>
> Here's a quick proof-of-concept, for the ';' command only. It may fail
> in some situations. I couldn't get it working right in visual mode:
>
And here is a more complete solution, with visual mode and the ,
motion also working:
nnoremap ; :<C-U>call DoubleJumpIfNoMove(v:count1, ';')<CR>
onoremap ; v:<C-U>call DoubleJumpIfNoMove(v:count1, ';')<CR>
xnoremap ; :<C-U>call DoubleJumpIfNoMove(v:count1, ';', 1)<CR>
nnoremap , :<C-U>call DoubleJumpIfNoMove(v:count1, ',')<CR>
onoremap , v:<C-U>call DoubleJumpIfNoMove(v:count1, ',')<CR>
xnoremap , :<C-U>call DoubleJumpIfNoMove(v:count1, ',', 1)<CR>
fun! DoubleJumpIfNoMove(count, op, ...)
let cmdprefix=''
if a:0
normal! gv
endif
if a:count==1
let curpos=getpos('.')
exec 'normal!' a:op
if curpos==getpos('.')
exec 'normal! 2'.a:op
endif
else
exec 'normal! '.a:count.a:op
endif
endfun
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php