Good day,

I am struggling with remapping the space key functionality. In particular, when I am using emacs with the evil mode I want to be able to use space when moving around in normal mode. I would like to map insert whitespace to M-SPC. However, since there seems to be no function for inserting space I don't know how to make it work. Your help is appreciated.

1 Answer 1


You can use kbd for defining the keybinding. You can look up the string that kbd expects by using C-h k M-SPC. Subsequently, you can just use the insert function inside a command to insert some string. A command is just a function starting with an interactive special form.

Finally, you can either define your custom named command and bind that, or use an anonymous command directly as follows:

(evil-global-set-key 'normal (kbd "M-SPC") (lambda () (interactive) (insert " ")))
  • Wow, this is genius, this works right of the scratch.
    – Rareform
    Commented Jun 12, 2022 at 12:46

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.