Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
447
rated 0 times [  447] [ 0]  / answers: 1 / hits: 169763  / 2 Years ago, sat, august 13, 2022, 12:57:33

I understand that vi has shortcut keys to delete characters, words and lines with various options.



However, I could not find this:




  • delete from the cursor to the next specified character



For example, I might type du" expecting the editor to "delete until the next " character is found"



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



Does anyone know if this is possible?


More From » vim

 Answers
7

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.


[#43169] Sunday, August 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
turhizz

Total Points: 82
Total Questions: 106
Total Answers: 96

Location: South Korea
Member since Mon, Dec 6, 2021
2 Years ago
turhizz questions
;