If the new text is the same length as the old text, Vim's replace mode is an option. From normal mode, R (that's a capital "r") brings you into replace mode. This is similar to "overwrite" in some other text editors: instead of inserting new characters like in insert mode, typing will replace the character under the cursor, and then advance to the next cursor. (Think of it like the lower-case
r, but for more than just a single character at a time.) Find the documentation for replace mode with
In your case: with the cursor between the
. and the
x, get in to replace mode by pressing R. Now when you type g it replaces the "x" and moves to the next character, so you can type h to replace the "y". Your edit is done now, so Escape to return to to normal mode.
(This works when your replacement text is the same length as the old text, but if your replacement is longer or shorter,
c might be all you need: it will replace1 the text within a movement, with the text you then type. There are many ways to do use
c, for example: with the cursor between the
ABCEscape says to change the text (up 'til the next
.) with "ABC".)
1 It'll yank the text in the movement into the unnamed/
" register and then switch into insert mode, so that you can type something to replace it, and then Escape back to normal mode.
Renters Replace Mode.
:help replace-modefor more information.
vt.rgh. But the result was the same as yours except for the cursor position.
cwgh<esc>would work fine.
minimize-keystrokesis a good tag, it's usually not really what the question is about, as such. (I rejected your proposed edits) ... Perhaps you should discuss at meta?