Picture of Michael Lee
:wave: Hey hey, I'm Michael Lee and this is my site about being a developer, being a dad and making side projects.

Deleting a word in Vim

Written on May 4, 2017

After listening to the latest episode of Dads in Dev, I wanted to see if I could use Vim for more than a short burst of my day.

I usually use Vim to write and do some minor code editing, but have always shied away from trying to use it as my main text-editor. This is because I’m usually too slow with my movements and I’ll get frustrated and just fire up Atom.

One of the points of slowdowns in my Vim workflow was deleting words. I would move the cursor over the beginning of a word and then hold down x until the entire word was deleted.

Curious to see if there was a better (or Vim) way of deleting words, I did a Google search and came across daw. While in normal mode, you just place your cursor anywhere in the word you’re trying to delete and type daw sequentially on your keyboard.

What the acronym daw stands for is delete around word. Which means it’ll delete the word under your cursor as well the spaces before and after the word. Definitely helps in remembering the key sequence.

Special thanks to Andrew Del Prete of Dads in Dev reading over my article and for correcting my understanding of how daw works

Thanks for taking the time to read this article. I'd love to stay in touch and share more tips on programming and design and side projects. Sign up and I'll send you my articles straight to your email.