I would also like to know if there are other ways to delete 4 words after the cursor.
I know 4de
and 4dw
delete 4 words after the cursor and 4db
will delete 4 words in front of the cursor, but when I'm in the middle of a word like below:
// SO|ME RANDOM CODE HERE
the result from running 4de
and 4dw
is:
// SO|
instead of deleting all 4 words.
Thanks for any help!
Deleting Multiple Lines Press the Esc key to go to normal mode. Place the cursor on the first line you want to delete. Type 5dd and hit Enter to delete the next five lines.
d^ will delete from current backward to first non-white-space character. d0 will delete from current backward to beginning of line. dw deletes current to end of current word (including trailing space) db deletes current to beginning of current word.
In order to delete lines matching a pattern in a file using vim editor, you can use ex command, g in combination with d command. To remove lines that contains the string amos , in vim command mode, type the command below and press Enter. This will delete all lines containing the specified keywords.
4dw
deletes using a text motion: it is four times "delete from here to where I jump by w
", which deletes the end of the word four times.
Use text objects instead: 4daw
is four times "delete a word", or delete four words.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With