In Vim, 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. i or I or o or suchlike), and then inserts the expected text. On subsequent invocations, it does not appear to do anything.

1 Answer 1


evil-repeat does something else, it repeats the last command, not insertion. Here's an approach actually going for what you've described C-a to do.

(defun my-evil-paste-last-insertion ()
  (evil-paste-from-register ?.))

(eval-after-load 'evil-maps
  '(define-key evil-insert-state-map (kbd "C-a") 'my-evil-paste-last-insertion))

edit: It's part of Evil now!

  • Yes, and thank you :) Ticket now open.
    – user8341
    Aug 8, 2015 at 17:49
  • @wasamasa: thanks for getting it into Evil!
    – Dan
    Aug 9, 2015 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.