Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Motion to last character

Tags:

vim

motion

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

like image 550
Lerp Avatar asked Oct 14 '13 08:10

Lerp


People also ask

How do you go to the last character in vi?

Press e (“end”) to move the cursor to the last character of the current word.

What is a Vim motion?

Motions (as in movements) are how you move around in Vim. They are commands that when typed move the cursor around with high speed and precision. There are many of them, and each one is best suited for different types and lengths of movement.

Which character is displayed after the end of the file Vim?

The end-of-line character ( lcs-eol , $ by default) is displayed at the end of file (EOF), no matter if the file actually ends with a newline. Neither disabling the fixeol setting ( :set nofixeol ), nor starting Vim in binary mode ( vim --clean -b bar ) affects this behavior.

How do you move the cursor to the end of the line in vi?

Press ^ to move the cursor to the start of the current line. Press $ to move the cursor to the end of the current line.


2 Answers

$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.

like image 145
pfnuesel Avatar answered Oct 06 '22 06:10

pfnuesel


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.

like image 33
Ingo Karkat Avatar answered Oct 06 '22 06:10

Ingo Karkat