Vim repeat append something at end of word

vim

Solution

ea`_old`ESCe.e.e. should work for you.

Another possible solution would be to use the `c` flag on a search and replace command:

:.s/\<[[:alnum:]]\+\>/&_old/gc

Then all you have to do is press y to confirm each replacement. This would be faster if you have a lot of replacements to do and want to confirm each one manually. If, on the other hand, you want to add `_old` to every word on a line, you can remove the `c`:

:.s/\<[[:alnum:]]\+\>/&_old/g

Problem

In vim I frequently find myself wanting to append a suffix to an identifier in my source code, and to then repeat it on other identifiers using '.'. i.e. to transform: ``` foo bar baz faz ``` to: ``` foo_old bar_old baz_old faz_old ``` I would like to be able to do: ``` ea_old<ESC>w.w.w. ``` instead of: ``` ea_old<ESC>wea_old<ESC>wea_old<ESC>wea_old<ESC> ``` In other words, I want appending text to the end of a word to appear as a repeatable command in the history. Anyone know how to do this? I can do: ``` nmap <C-a> ea ``` to create a slightly more convenient way to append at the end of a word, but it only repeats the "a". Ideally I want to be able to repeat the whole "eaarbitrarytext" sequence. I have the repeat.vim plugin installed and tinkered a bit, but I don't really know what I'm doing in vimscript. Clarifying the requirement: I want to be able to jump around using arbitrary movement commands until my cursor is somewhere on the identifier, and then hit "." to repeat the appending of a suffix. The above example is intended to be a special case.

Original source