agctute
agctute

Reputation: 141

Vim: delete up to nth specified character

I'm pretty new to vim and I just learned that you can use dtx or dfx to delete up to x and up to and including x respectively. Is there a way to choose which occurrence of x to delete to? For example, if I have the line

peter piper picked a pickled pepper

and I wanted to delete up to the fifth p to obtain

pickled pepper

What commands would I be able to use to do this?

Upvotes: 0

Views: 160

Answers (2)

balki
balki

Reputation: 27674

Using visual mode to select and ; to move to next occurrence makes it easier than counting.

vtp;;;x

Upvotes: 1

Ry-
Ry-

Reputation: 224859

You can give motions counts even within d:

d4tp

Upvotes: 4

Related Questions