Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Auto-Indent

0 views
Skip to first unread message

Stefan Korinek

unread,
Oct 1, 2001, 5:39:54 AM10/1/01
to
Hello,

I am a emacs-newbie and I'd like to know how to switch to
Auto-Indent-Mode. I just want to write structured code, but switching
to c-mode, as well as the menu option doesn't have the desired effect.

Thanks for help

Eli Zaretskii

unread,
Oct 1, 2001, 6:14:30 AM10/1/01
to

If by ``auto-indent'' you mean that pressing RET automatically indents the
next line, then press C-j (or LFD, if your keyboard has it) instead of RET.

James A. Crippen

unread,
Oct 1, 2001, 3:57:24 PM10/1/01
to
Eli Zaretskii <el...@is.elta.co.il> writes:

Or try rebinding RET to call newline-and-indent.

I do the following for eg CC-mode:

(add-hook 'c-mode-hook
#'(lambda ()
(define-key c-mode-map [(return)] 'newline-and-indent)))

I do the define-key in the mode hook because that way RET isn't
rebound for *every* mode, and the c-mode-map may not exist if a c-mode
buffer hasn't been opened yet, but it will when the hook is called. I
have one of these for each mode that I want auto-indentation in. Ie,
one for Lisp-Mode, one for Outline-Mode, one for C++-Mode, etc.

This is easier than pressing C-j all the time, which wears out my
thumb.

'james

--
James A. Crippen <ja...@unlambda.com> ,-./-. Anchorage, Alaska,
Lambda Unlimited: Recursion 'R' Us | |/ | USA, 61.2069 N, 149.766 W,
Y = \f.(\x.f(xx)) (\x.f(xx)) | |\ | Earth, Sol System,
Y(F) = F(Y(F)) \_,-_/ Milky Way.

Justin Murdock

unread,
Oct 4, 2001, 11:19:45 AM10/4/01
to
>>>>> On 01 Oct 2001 11:57:24 -0800, James A Crippen ( = "JAC> ") wrote
>>>>> in article <m3lmiv6...@kappa.unlambda.com>:

JAC> Eli Zaretskii <el...@is.elta.co.il> writes:
>> Stefan Korinek wrote:
>>>> I am a emacs-newbie and I'd like to know how to switch to
>>>> Auto-Indent-Mode. I just want to write structured code, but
>>>> switching to c-mode, as well as the menu option doesn't have the
>>>> desired effect.
>> If by ``auto-indent'' you mean that pressing RET automatically
>> indents the next line, then press C-j (or LFD, if your keyboard has
>> it) instead of RET.

JAC> Or try rebinding RET to call newline-and-indent.

JAC> I do the following for eg CC-mode:

JAC> (add-hook 'c-mode-hook #'(lambda () (define-key c-mode-map
JAC> [(return)] 'newline-and-indent)))

I use reindent-then-newline-and-indent, and I also bind C-j to newline.

Geoff Wozniak

unread,
Oct 13, 2001, 1:57:52 AM10/13/01
to
Stefan Korinek <kor...@hdz-ima.rwth-aachen.de> writes:

As others have said, in c-mode C-j is bound to `newline-and-indent',
which you can rebind to RET. If you want to try something similar,
you could turn on auto-state with C-c C-a which automatically enters
newlines and indents on some characters.

--
Geoff(rey) Wozniak, Limited Duties Instructor
University of Western Ontario
Computer Science (Graduate) Department
London, Ontario, Canada
http://woz.killdash9.org/

GPG Key: http://woz.killdash9.org/misc/woz.gpg

He who knows best knows how little he knows.
-- Benjamin Franklin

0 new messages