Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 36 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

share|improve this answer
    
Exactly what i was after! Thanks @Arcege! –  kctang Oct 8 '11 at 18:02
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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