How to delete multiple words?

To delete multiple words in Vim, you can use the d command followed by a movement command. Here are a couple of methods:

Method 1: Using dw with a count

You can specify a count before dw to delete multiple words. For example, to delete the next 3 words:

  1. Place the cursor at the beginning of the first word you want to delete.
  2. Type d3w.

Method 2: Using d with a movement command

You can also use the d command with a movement command like e (end of word) or W (to the next word):

  • To delete until the end of the third word:

    • Type d3e (this deletes from the cursor to the end of the third word).
  • To delete a specific number of words regardless of punctuation:

    • Type d3W (this deletes the next three words, treating punctuation as part of the word).

Example:

If your text is:

Hello World this is Vim

And your cursor is at the H in "Hello", typing d3w will result in:

 is Vim

These methods allow you to efficiently delete multiple words in Vim.

0 Comments

no data
Be the first to share your comment!