I don't really like how AUCTeX indents latex code, and overall I find it pretty unpredictable (I guess I'm not used to the way it works). Some modes just bind the tab key to "move the current line so that it begins at next tab stop". Is there a way to achieve this in AUCTeX? Ideally, lines would be indented with spaces.

Similarly, is there a way to bind Shift+Tab to "indent the current line back to previous tab stop"?

I managed to change the behaviour of the Tab key, but only to insert tabs at the current position, which isn't really great.

  • 1
    I can't answer to your question but I would suggest you to don't use tabs because if you oper your files with other programs you'll loose formatting of the code! – Spike Jun 11 '11 at 9:17
  • 2
    Same goes for me, Clement. I've been working with AUCTeX for almost two years. I'd be glad, if someone gives a few hints. – Keks Dose Jun 11 '11 at 14:19
  • You'll probably get good answers if you ask this on stackoverflow with a title like Bind <TAB> and <Shift+TAB> to increase and decrease indentation – Malabarba Feb 5 '13 at 19:39

Alright, I'm not very good with emacs, but since no one else seems to have any ideas I thought I'd have a stab at providing the resources that might help fix the problem:

I found the following note which looks promising:

M-i Indent from point to the next prespecified tab stop column (tab-to-tab-stop).


If you just want to insert a tab character in the buffer, you can type C-q TAB.

You should be able to rebind the key to M-i, or whatever function M-i calls. There is more information on this in the second on Tab Stops.

Other resources I've found that might help:

http://www.emacswiki.org/emacs/IndentingC#toc7 Describes how to turn off automatic tabbing and have it insert a tabstop each time tab is pressed. However this is for c-mode, and I don't know if the hooks are the same for ACUTeX.

http://www.gnu.org/software/emacs/manual/html_node/ccmode/Indentation-Commands.html#Indentation-Commands describes how to make the key simply insert either a set number of spaces or a tab-character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.