vi shortcut to delete "until the next X character"

Solution 1:

Use dtc, where c is any character, e.g. for you, you want dt"

This will delete upto but not including c.

If you had:

delete until exclamation point!

And the cursor was at the first space and you typed dt!, you would get:

delete!

Also dfc.

This will delete upto and including c.

Using df! on the same example above would give you:

delete

Just about any "motion" can be used for the d, c, y and similar commands.

Solution 2:

  • To delete forward up to character 'X' type dtX

  • To delete forward through character 'X' type dfX

  • To delete backward up to character 'X' type dTX

  • To delete backward through character 'X' type dFX

Solution 3:

The input dt# (not a :command, use it like a movement like G)

will delete from the cursor until but not including the #. You can substitute any char for #.

Solution 4:

It looks like @Arcege already answered the question, but I did d/l to delete until the character l; other characters would work as well.

Solution 5:

w moves to the following word. l moves to the following charactor.

So it's d9l to delete the next 9 characters.