I'm fairly new to aquamacs/emacs and while editing I noticed that it indents however it wants. In order to indent the way I want I end up using M-i, but that is pretty cumbersome. So, how do I make the TAB key behave like M-i (that is, inserting 4 spaces whenever I press it, regardless of the type of file I am editing)?
Asked
Active
Viewed 236 times
0
1 Answers
2
You can find out the command that is executed by M-i
,
C-h k M-i
and bind it to TAB
:
(global-set-key (kbd "TAB") #'tab-to-tab-stop)
However, this will set the global binding, while you are most likely concerned with the binding of one or more global modes:
(add-hook c-mode-common-hook #'(lambda () (local-set-key (kbd "TAB" #'tab-to-tab-stop))))
But perhaps it would be better if you could describe what are your issues with Emacs' indentation (in a different question), so we can help you solve that.

jch
- 5,720
- 1
- 23
- 39
M-i
calls to thetab
key. You can check what command that is withC-h k M-i
(describe-key
). You can also have a look at how to bind keys in the Emacs manual and on Xah Lee's tutorial. Just a heads-up, though: a lot of packages and libraries make extensive use of thetab
key for things other than indentation, so you may not want to overwrite those bindings. – Dan Jan 09 '15 at 22:43