vi shortcut to delete "until the next X character"

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.


  • 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


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

Tags:

Vim