Selon Christian Brabandt <[email protected]>:

> Hi neolus!
>
> On Mi, 03 Apr 2013, neolus wrote:
>
> > Hi! is there any fast neat way to tell vim not to go to next/previous word
> if
> > it's on a different line that doesn't require writing a function? e.g. a
> > flag or something? I looked but can't find anything on it other than
> > whichwrap but it seems that only applies to hjkl stuff..
>
> I am afraid it is not possible without writing a function:
>
>
> fu! MyWordMovement(fwd)
>     if a:fwd
>         return ':call search('.string('\%'.line('.').'l\<'). ',"W")'."\<cr>"
>     else
>         return ':call search('.string('\%'.line('.').'l\<'). ',"bW")'."\<cr>"
>     endif
> endfu
> nnoremap <silent> <expr> w MyWordMovement(1)
> nnoremap <silent> <expr> b MyWordMovement(0)
>
> Quoting is a little bit nastyš, but seems to work for me.

I think the following is slightly less nasty :)

  fu! MyWordMovement(backward)
    if search('\<', 'n' . a:backward, line('.'))
      return len(a:backward) ? "b" : "w"
    else
      return "\<Esc>"
    endif
  endfunction
  nnoremap <silent> <expr> w MyWordMovement("")
  nnoremap <silent> <expr> b MyWordMovement("b")

Best,
Paul

-- 
-- 
You received this message from the "vim_use" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to