In evil insert state, I can mark a region in the buffer using the mouse. If I now press the Delete key (bound to the delete-char command) it deletes the character at the current cursor position and not the the marked region. This behavior is different from how the delete key works in normal Emacs mode where the region is killed. How can I make evil insert mode work the same way?

1 Answer 1


If I understand correctly, you're asking about the behavior of DELETE when the region is active, or, as far as evil is concerned, when you're in evil's visual state. It should be enough to rebind the key in that map:

(define-key evil-visual-state-map [delete] #'delete-region)

Update: as @HakonHaegland's comment indicates, it's not exactly clear what's going on with the different states. However, using the following keybinding seems to resolve the issue:

(define-key evil-insert-state-map [delete] #'evil-delete-char)
  • Actually, I am quite convinced that I am in evil's insert state. In visual state I usually use d to delete the region. Also, if the region is not active, I would like to have the normal delete-char to be called, so delete-region will not work correctly if there is no marked region. I tried to replace your delete-region with evil-delete-char and it seems to work fine. Jul 26, 2016 at 17:08
  • @HåkonHægland: I might be misunderstanding, but I think the region is always active in visual state. You can check by marking the region with your mouse as you described, then M-: (use-region-p) to check if the region is active. You can also do M-: evil-state to determine which state you're in.
    – Dan
    Jul 27, 2016 at 2:41
  • Thanks. If I try M-: evil-state it says insert. So it is as expected. Jul 27, 2016 at 6:40
  • @HåkonHægland: sorry, do you mean updating it about the evil-delete-char function that you tried?
    – Dan
    Jul 27, 2016 at 14:43
  • @HåkonHægland: done! Still can't figure out what's going on with the different states, but I'm glad you got it working.
    – Dan
    Jul 27, 2016 at 14:49

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.