To my mind, one of the most confusing and arcane “everyday things” in Emacs is the subject of tabs, the Tab key, and indentation. I’ve been using Emacs for over a decade but I still remember how hard it was for me to get Emacs configured to do what I wanted. Back in those days, I was still doing a lot of C coding and the default behavior of C indentation was so odd and off-putting that I almost gave up on Emacs and went back to Vim. Being a n00b, I had no idea how to fix things so I asked Google and found some configuration items to put in my init.el
that made things work correctly.
When I was researching this post, I searched my init.el
for “indent” and found that I still wasn’t clear on what some of those configuration items were doing. These days, of course, I know how to look them up but you’d think after all this time I’d understand these things a little better.
Doug Beney to the rescue. Over at dougie.io he has a very useful post that discusses how to get tabs and spaces to work as you’d like them to. It’s definitely worth reading to get a handle on how to get indentation and the Tab key working in a sane manner.
Beney likes using tabs instead of spaces and his default configuration reflects that. I’ve never cared much about that controversy but I’ve come to believe that spaces are the better answer (this despite my using tabs in my Vim days). Beney is careful to show how to configure things to use spaces and even provides a couple of functions to enable one or the other so if you’re in the spaces camp, the post is still useful.