Given the following sentence:
This is one two three.
When I move the cursor to the space between one and two, I would like to replace two with XXX.
I know there is a way in vi so that I can mark two as the modified string so that when I finish entering the new string and the new string replaces the two in-place.
// Update-1 //
The corresponding command in vi is ‘cw’
I would probably just use M-d SPC X X X (if the SPC is necessary depends on wether the cursor is placed directly after “one” or before “two”) or M-f M-DEL X X X, but maybe that’s not what you’re looking for.
Ok, you didn’t answer my comment, and didn’t vote up an answer, so I guessed what you might like and here is a little hack:
Invoke M-x change-word (or bind it to a key you like), edit the word, and type C-c C-c when you’re done. If you want to edit the next
nwords, give it a prefix argument (e.g. M-3 M-x change-word to change the next three words). It’s not exactly the same — You’ll edit in another buffer — but it comes close. Try and see if you like it. It is not a very elaborate solution. Maybe the best, and most emacs-style approach, would be to have something akin to isearch-mode, that highlights the changed region and so on. Note that you’ll have to(require 'cl)because oflexical-let.Another possibility would be something like this:
But this example is just a very crude hack — You won’t even be able to navigate while editing your word. Maybe one could write something modifying the command-loop behavior, but I didn’t look into that.
I don’t know about any built-in functionality that does exactly what you seem to want, but of course there are Viper and other Vi emulation modes built in.