Search code examples
vim

vim deleting backward tricks


  • How does one delete a word to the left? In other words, delete the word when the cursor stands at the end of it.
  • How does one delete characters to the beginning of the line?
  • How does one delete to the first whitespace to the left?

  • Any other tricks involving word deletion?


Solution

  • In general, d<motion> will delete from current position to ending position after <motion>. This means that:

    1. d<leftArrow> will delete current and left character
    2. d$ will delete from current position to end of line
    3. d^ will delete from current backward to first non-white-space character
    4. d0 will delete from current backward to beginning of line
    5. dw deletes current to end of current word (including trailing space)
    6. db deletes current to beginning of current word

    Read this to learn all the things you can combine with the 'd' command.