Wednesday, April 3, 2013

Re: do word jump commands without line-wrap?

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.

š) it is probably easier to check, whether the next word movement would
change lines and in that case return esc else return the normal w/b
movement keys, but now I have already written down this function...

Mit freundlichen Grüßen
Christian
--
_.oooO__Oooo._
_(___)__(___)_
__\_(____)_/__
___\_)__(_/___

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment