Making inserting a single character in Vim an atomic operation

Viewed 3371

I've long used this very useful shortcut in vim:

nmap <space> i <esc>r

this means that if I press spacef, for example, it will insert a single character f at the given position.

unfortunately, however, this is not atomic, ie, if I press spacef and then navigate somewhere else, then press ., I get the equivalent of rf, not spacef.

all this makes sense, but here's the question: is there a way of making this atomic, so that . will repeat the 'insert character' operation, and so that undo etc all treat it as one operation, too?

5 Answers
Related