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

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

Re: indentation in c++


From: Alan Mackenzie
Subject: Re: indentation in c++
Date: Sat, 5 Mar 2005 08:41:54 +0000
User-agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686))

prab@spectral.com wrote on 3 Mar 2005 12:58:13 -0800:
> How do I customize Emacs so that when editing a C++ file the
> indentation of for loops, etc., will be 3 spaces instead of the default
> of 2 spaces? 

> We have GNU emacs version 21.2.1

A default of 2 spaces?  UURRRRKKKK!!!   How horrible!

The variable you need to change is c-basic-offset, and it's documented in
the CC Mode manual on the page "Customizing Indentation".  How you would
go about setting it is on the page "Sample .emacs File".

First, why not check through your .emacs and find if it's getting set to
2 there?  If so, just change it.

Otherwise put something like this into your .emacs:

(defun prab-c++-hook ()
  (setq c-basic-offset 3))
(add-hook 'c++-mode-hook 'prab-c++-hook)

(_Don't_ forget the two quote marks in that last line.)

> We have GNU emacs version 21.2.1

-- 
Alan Mackenzie (Munich, Germany)
Email: aacm@muuc.dee; to decode, wherever there is a repeated letter
(like "aa"), remove half of them (leaving, say, "a").



reply via email to

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