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?

1
  • 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 7, 2015 at 7:44

1 Answer 1

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)
1
  • Also for reference: the manual page on tabs vs spaces, which discusses precisely this issue.
    – Dan
    Mar 7, 2015 at 4:50

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.