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?

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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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