Search code examples
emacsinitializationelispindentation

emacs: turning electric-indent-mode on/off easily


I'm a bit of an elisp newbie. How can I tell emacs to toggle electric-indent-mode when I press "C-c e" ?

I tried

 (global-set-key (kbd "C-c e") 'toggle-electric-indent-mode)

but that does't seem to do it for me.


Solution

  • The mode is just a function that you can call. Try:

    (global-set-key (kbd "C-c e") 'electric-indent-mode)