Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just found out about f and its siblings (t,F,T) and naturally I am intrigued (they seem slightly more efficient than using / - especially with commands like d). But they do not follow line breaks. For instance:

my text
more text

Let's pretend I was on the y in the first line in normal mode. If I type fr I would expect to go to the r in the second line. But it stops at the end of line.

Is there a way to tell these commands to wrap around?

share|improve this question

1 Answer 1

[Edit: Changing No to Probably but keeping original answer for reference. See below.]

No. See

:help left-right-motions


Edit:

Probably. There is an example of mapping f to a function that performs a case-insenstive find at the end of

:help getchar()

That could be easily modified to perform a search for the given character instead of just a find.

To get this to work as a motion command following d, for example, you would have to define f as an operator-pending mapping. See

:help omap-info

I wrote "probably" rather than "yes" because I don't have any personal experience with operator-pending mappings so I haven't verified that that will work in this case.

share|improve this answer
    
When I said *Is there a way" I actually meant "How", because I'm sure that it works somehow. Via some mapping to a function or something, perhaps? I don't know enough of the Vim scripting language to figure it out, but I think it should be possible. –  bitmask Aug 29 '11 at 23:33
    
I looked but didn't find anything promising. Apparently I didn't look hard enough. Take a look at :help getchar() and scroll to the bottom. There's an example that 'redefines "f" to ignore case.' With a little work, you could make it search additional lines. To get this to work as a motion command following d, for example, you'll have to define f as an operator-pending mapping. See :help omap-info. Sorry I don't have a ready-made solution at the moment. –  garyjohn Aug 30 '11 at 0:50
    
@Lance Roberts: Thank you. How's that? –  garyjohn Aug 30 '11 at 23:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.