VimTrick: Quick Replacements
Colin Bartlett

Colin Bartlett @cbartlett

About: I help IT teams monitor the cloud with StatusGator. Vim user and author at VimTricks.com

Location:
New York, NY, USA
Joined:
Apr 25, 2020

VimTrick: Quick Replacements

Publish Date: May 21 '20
3 0

Everyone is aware that x deletes the character under your cursor. But if you’re making a lot of changes this way, you can quickly exact a severe toll on your x key. When changing chunks of text, your efficiency as well as your wear and tear on the keyboard can benefit greatly by using a few actions and motions:

  • dtc - delete to the next c
  • ci} - change inside the curly braces
  • cf, - change forward to and include the comma
  • di” - delete inside the quotes. This does not delete the quotes.
  • ya’ - yank around single quotes. This includes the quotes. (The yanked value can be pasted with p. Try using the clipboard register to paste somewhere else!)

Some obvious mnemonics emerge: d for delete and c for change. The difference between change and delete is simple: Change drops you into insert mode, ready to type replacement text. Delete leaves you in normal mode, so you can perform another edit.

There are tons of combinations you can make from these. We've got a short demo screencast over on our VimTricks post.

Comments 0 total

    Add comment