5

When I open Java files originally created and edited in Emacs, the indentation shows up correctly, as in the image below:

Java file made in emacs

However, when I open the same file in Sublime Text, or any other editor besides Emacs, the indentation is messed up, and I can see that it's because Emacs inconsistently mixes spaces and tabs:

The same file opened in sublime text

Has anyone else encountered this?

Drew
  • 75,699
  • 9
  • 109
  • 225
Adam R
  • 53
  • 3
  • That's happening because your Emacs is using a tab width of 8, while sublime is using a tab width of 4. That's easy to fix, but if it's an option at all I would just follow Drew's answer and stop using tabs. – Malabarba Mar 07 '15 at 07:44

1 Answers1

6

Set option indent-tabs-mode to nil:

Put this in your init file, to make Emacs always indent using SPC characters, never TAB characters.

(setq-default indent-tabs-mode nil)
Drew
  • 75,699
  • 9
  • 109
  • 225
  • Also for reference: the manual page on [tabs vs spaces](https://www.gnu.org/software/emacs/manual/html_node/emacs/Just-Spaces.html), which discusses precisely this issue. – Dan Mar 07 '15 at 04:50