I understand that vi has shortcut keys to delete character, word and line with various options. However, I could not find this:

  • to delete from cursor to the next specified character. I might type du" (example) expecting the editor to "delete until the next double quote character is found"

The closest I know is the d9w where 9 is the number of words to delete.

Anyone knows if this is possible?

link|improve this question
feedback

3 Answers

up vote 7 down vote accepted

Use dfc.

If you had:

delete until exclamation point!

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

delete

Also dtc. This will delete upto but not including c. Using dt! on the same example above would give you:

delete!

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

link|improve this answer
Exactly what i was after! Thanks @Arcege! – koss Oct 8 '11 at 18:02
feedback

No, it is not possible. (#) dw is the closest that you can get. For more streamlined options like that in an editor, use sed
http://www.grymoire.com/Unix/Sed.html

link|improve this answer
feedback

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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.