I am trying to make a mapping that performs what f
would normally do if there is a character match on the line, and to do something else if no such character exists. For example,
suppose if I had the following line of text.
The dog _runs fast
,
where the _
represents my cursor position. If I press fa
, I would want my cursor to be on a
as normal, but if I press fx
, then I want to add additional functionality. I have looked into something like retrieving the number of occurrences of a character with search()
, but I'm don't think there is a range option that only searches the current line past the cursor.
For context, my goal is to make a mapping like f
, F
, etc... that wraps around the current line. So that (in the case of f
), if there is no matching character past my cursor, it will then search for the same character starting from the beginning of the line.
Thank you
search()
does havestopline
, though there may be easier ways