Unknown Vim Trick
One of beautiful thing about vim
is that you can learn something even after
using 5+ years. Even though usual vim learning curve characterized like below:
This is the command I’ve been looking for a long time. I accidentally saw it on one of the ThePrimeagen video.
Entrée
Let’s assume that I’m on the line 5 and want to update "_cache_update_cache"
on the line 30, to "_cache_update_current"
.
|
|
What I was doing: press 25jf"ci"
on Normal
mode, which means:
25j
: down 25 linef"
: find the first occurrence of"
ci"
: change inside of"
and then write _cache_update_current
.
The annoying part is you have to press additional f"
every time. For a normal
user it probably means nothing, but for a vim
user it means a lot, since
“Real Vim ninjas count every keystroke”1
Therefore I was using a macro
and key binding
for this. Until now.
Trick
The trick is just press ci"
; you don’t have to press additional f"
(for an
unknown reason it works which shouldn’t). So our above command is just 25jci"
now.
And it works with usual text objects like {, [, *, '
etc.
All done!