help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: No automatic tabs in Emacs?


From: PJ Weisberg
Subject: Re: No automatic tabs in Emacs?
Date: Wed, 1 Dec 2010 20:04:01 -0800

> I'm writing on C my code:
>
> #include "stdio.h"
> int main(){
> }
>
> And I wanna add something to main. I push Enter and write my code. In Emacs I 
> get this:
>
> #include "stdio.h"
> int main(){
> printf("Hello World");
> }

Actually you don't, because emacs by default indents the line when you
press ';'. ;-)

There might be a better way to do it, but you can accomplish what you
describe by putting this in your .emacs file:

(defadvice newline (after always-auto-indent)
  (indent-according-to-mode))
(ad-activate 'newline)

I'm personally at the point where I'm sometimes surprised when I
unconsciously press TAB in another editor and it inserts some
whitespace at the cursor instead of fixing my indentation.  If you've
really got a love for having the editor take care of your whitespace,
try this:

(c-toggle-auto-newline 1)
(c-toggle-hungry-state 1)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]