Be productive with Vim – Part 3: Deletion
Get to know Vim’s main deletion commands. Delete words, lines, and characters, and pick up a few more tips. All with just a handful of commands.

Editorial translation by Impulso.
Heeey, Impulser. In the last chapter, we talked about navigation commands, and now we’re going to introduce deletion commands.
If you landed here first and want to check out the previous articles:
- Be productive with Vim – Part 1: Essential commands
- Be productive with Vim – Part 2: Navigation
If you want to start practicing with Vim, be sure to read the earlier articles and keep an eye out for the next ones. So let’s get to it!
Usage
Delete individual characters
The first command to mention here is X. This key deletes the selected character. As always, following the same logic with Shift, we can use Shift + X to delete everything on the current line from the cursor backward.
Delete with motions
We can also delete using “motions” in Vim with the D key. You can also pass a navigation key as the second argument. For example, D + $ deletes everything from the cursor to the end of the current line, which is the same result you get with Shift + D.
By the way, do you still remember how to move by words (Word), W? If you do, you can combine that with the D operator. For example, to delete the current word, use D + W, and for words with punctuation, use D + Shift + W. The same logic applies in reverse with D + B and D + Shift + B. Keep trying these out in your editor so they stick. Deal?
Delete lines
Of course, there are also commands to delete the entire current line. For that, D + D does the trick.
In Vim, operators take an optional count as an argument. For example, D + 3 + W deletes the next 3 words. So we can use 3 + D + D to delete the next 3 lines.
Wrapping up
In this chapter, we got an overview of deletion operators, and in the next chapter we’ll talk a bit about cutting, copying, and pasting in Vim. So, ready to go?
See you next time, folks!


