Lerp
Lerp

Reputation: 3127

Motion to last character

Is there a motion to move to the last of a character?

Example:

[A]pple -> move to last p -> Ap[p]le

I can do that with 2fp but if there's lots of "p"s in the line then it's not so easy to count them then do 10fp

Upvotes: 5

Views: 234

Answers (5)

Christian Brabandt
Christian Brabandt

Reputation: 8248

My Vim plugin improved_ft also allows for this. Set let g:ft_improved_multichars = 1, press f and then type p followed by l.

Upvotes: 1

Ingo Karkat
Ingo Karkat

Reputation: 172590

My JumpToLastOccurrence plugin extends the built-in f / F / t / T motions with counterparts (by default bound to ,f etc.) that move to the last occurrence of {char} in the line.

Upvotes: 6

romainl
romainl

Reputation: 196566

There's no such motion.

But you could always do vfp;;;;d or v$Fpd.

Or find another more suitable target.

Or use a plugin like Easymotion.

Upvotes: 4

AD7six
AD7six

Reputation: 66217

Search from the end

Instead of looking for the last occurrence of a character - move to the end and look backwards for the first:

$Fp

Upvotes: 5

pfnuesel
pfnuesel

Reputation: 15320

$Fp

$ jumps to the end of the line, F jumps backwards to the character p.

This does not work if p is your last character.

Upvotes: 7

Related Questions