Ctrl-A can be used in Insert-mode to insert previously inserted text, much as the "dot" (
.) command can be used in Normal-mode. For context and a demonstration, watch from ~2m25s - 5m08s in George Brocklehurst's ThoughtBot talk, "Let Vim Do the Typing", or read the excerpt I've transcribed below.
There is a special register called "dot". The "dot" register contains whatever the last text you inserted was, the last time you were in Insert-mode. The last time I was in Insert-mode, I inserted "Hello<space>world<newline>", so if I go back into Insert-mode and I hit
Ctrl-R, and then I hit
., I reinsert that entire thing. But even cooler, if I just hit
Ctrl-A, Vim just does that for me.
My question is: how can I obtain this functionality in Evil mode?
With the default settings, entering
C-a while in the Insert state of Evil mode just moves my cursor to the beginning of the line.
I tried adding
(define-key evil-insert-state-map "\C-a" 'evil-repeat)
to my .emacs file after the call to Evil, but this does not behave quite as expected: on the first invocation after entering the Insert state, it inserts whatever character was previously used to enter the Insert state (e.g.
o or suchlike), and then inserts the expected text. On subsequent invocations, it does not appear to do anything.