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.
Top comments (0)