This answer might not be able to cover all cases where you see yourself doing many small edits on different locations of the same line, but I find that a good approach here is to try and turn them from many separate small insertions into a Normal mode action.
That often means adopting plug-ins implementing more complex actions, or also advanced text objects that can help select the right bits of text to act upon.
In the comments, you mentioned refactoring to replace getVal
with get_val
. Plug-in vim-abolish has a "coerce" operation under cr
to do case coercion, using crs
will perform case coercion to snake case on the current word, which is the transformation you're after. (cr_
also works.)
Another type of refactoring that typically involves small edits interspersed with movements is adding braces or parentheses around text. Plug-in vim-surround can help with that. You can surround text with ys
, for example ys"iw
to put double quotes around the current word. Or replace types of braces, cs])
to replace square brackets with parentheses. You can also use visual mode to select which text to surround.
For advanced text objects, I recommend targets.vim, which introduces some useful text objects for arguments of functions that can also be very helpful when refactoring code. It also introduces modifiers for the "next" (n
) and "last" (l
, more like "previous") text object, so you can act further away on the line you're in. For example, you can use dana
to delete the "next" argument if you're on top of a function call or an argument of a function call. Plug-in targets.vim includes many other helpful text objects and it also extends some built-in text objects in Vim to make them smarter.
Make sure you also have vim-repeat, which will allow you to use .
to repeat actions from plug-ins such as vim-abolish and vim-surround (among many others), which is important if you're using these actions repeatedly on many separate lines or matches.
In short: Try to reframe your small edits into an "action", which you'd execute in Normal mode, and consider embracing plug-ins which implement such actions for you.
because if the internet is to be believed, in the long run once you've got over the steep learning curve, it's better NOT to use the arrow keys. Or so a lot of people state, anyway
: this is nonsense propagated by Vim purists who hold the misguided view there is a One True Way™ to use Vim (namely, the way they prefer). If you like arrow keys: use them. If you don't: then don't. Simple as that.