File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Linux / UNIX and the fly likes emacs and annoying tab characters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "emacs and annoying tab characters" Watch "emacs and annoying tab characters" New topic

emacs and annoying tab characters

Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Actually, it's not the tab characters that annoy me. It's emacs behavior of mixing tabs and spaces in indentation. I often use emacs for coding but I'm really annoyed that it mixes tabs and spaces. Does anyone happen to know what I need to do to make emacs use only one or the other? Preferrably, I would like to use all spaces for indentation.

Thanks in advance!


Java API Documentation
The Java Tutorial
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

Hey, this is Emacs. It knows BETTER than you do! [TM]

Memory's a little fuzzy, but I think Meta+x "untabify" or something like that will get rid of the tabs. Do this:

Press ESC (Meta)
Press x (down there on the bottom row )
When the prompt appears down below the status line, type "untab" and press the tab key and it will look for possible completions. Hopefully there's only one, but at least that should give a hint. Actually, I think it may be "untabify-buffer". There may also be an untabify-region that you'd use to untabify a "highlighted" section of the buffer.

Press Enter to execute the command.

An IDE is no substitute for an Intelligent Developer.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

In your ~/.emacs file, put

This tells emacs to use all spaces instead of tabs, except in Makefiles, which need tabs to work correctly. If you never edit Makefiles, you could leave off everything but the first line.

[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Thanks for all the suggestions. I'll try them out when I get home tonight.

I agree. Here's the link:
subject: emacs and annoying tab characters
It's not a secret anymore!