I really appreciate the undo in region command in standard emacs, where you can just mark a region and only changes made in that region are undone.

This doesn't seem to work in the default spacemacs configuration.

Is there a way to activate this?

3 Answers 3


You can select the region and do, either: SPC SPC undo or C-_ that is Control-shift--key

or even better, you can create your own keymap under SPC o that's reserved for user keybindings, and create SPC o u for undo:

(spacemacs/declare-prefix "o" "personal")

;; File bindings
  "ou" 'undo)
  • 1
    Thanks. The C-_ command works, but the marked region extends after the first time I press it (weird, but not the end of the world). SPC SPC undo doesn't do this, oddly enough. Commented Apr 24, 2017 at 0:22
  • 1
    Also, it seems like a shorter undo history is kept then before. If I edit a region, then do an undo and redo somewhere else, the undo-history for the original region seems to be lost. Commented Apr 24, 2017 at 0:30
  • Actually, I can't reliably reproduce it now. Never mind. I'll post a new question if I manage to. Commented Apr 24, 2017 at 0:42

(define-key evil-visual-state-map (kbd "u") 'undo)

It will bind u to Emacs undo command in evil visual state (aka when you select region).

  • Thanks for your answer, would you mind adding some explanation to increase its usefullness?
    – JeanPierre
    Commented Apr 23, 2017 at 21:59

As of July 15, 2022, there exists a flag to enable undo-region with vim style key bindings in the Spacemacs develop -- which also happens to currently be the default, rolling release -- branch. Users can edit the .spacemacs file to include the following,

 (setq-default dotspacemacs-configuration-layers
                '((spacemacs-editing :variables
                                     vim-style-enable-undo-region t)))

For the related git pull request, see https://github.com/syl20bnr/spacemacs/pull/15631

  • What does "5 years later" mean? Could you please provide some info that identifies the particular version of Spacemacs (or whatever) that provides this? Presumably the link you show provides that info somewhere, but it really belongs in the answer text as well, to be most helpful. Thx.
    – Drew
    Commented Jul 17, 2022 at 20:38
  • 1
    I hate link rot as much as the next guy, answer updated. Appreciate the moderation towards high quality content. Commented Jul 19, 2022 at 2:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.