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

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

Re: Auto-indent new lines?


From: Matt Armstrong
Subject: Re: Auto-indent new lines?
Date: Sat, 3 Mar 2001 09:52:04 -0800
User-agent: Mutt/1.2.5i

On Sat, Mar 03, 2001 at 03:27:26PM -0000, Mark Newby wrote:
> No, it doesn't.  I've tried opening a .c file and it doesn't work in
> that either --all I get is the TAB key turned off, which is so
> anoying.  Surely this is basic behaviour of any coding environment,
> yet it's not even supported in what's meant to be the best editor in
> the world!  I need it to do it in shell script, html, perl, etc, in
> fact, doing it in all files would be ideal --why isn't it default?
> Maybe I should ask for it to be...
> 
> Doesn't anybody write code in Emacs?  What should I use instead then?

What you want is this in your .emacs:

    (global-set-key "\C-m" 'newline-and-indent)

This is not the default because C-j is bound to the same command.

Your TAB key is "turned off" because TAB is usually bound to a function
that indents the current line.  You can always insert a real tab with
C-q TAB.  For cc-mode, you might like:

    (setq c-tab-always-indent nil)

which makes TAB indent the line only when pressed at the beginning of
the line, otherwise it adds whitespace up to the next tabstop.

You can read up on indentation in the Emacs info manual (M-x info,
select Emacs, then search for "indentation").  The cc-mode specific
stuff is in the cc-mode manual.



reply via email to

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