unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Re: Customizing tab indentation width
  2003-09-20 15:13 Customizing tab indentation width Sona
@ 2003-09-20 14:52 ` Dave Footitt
  2003-09-22  8:51 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Footitt @ 2003-09-20 14:52 UTC (permalink / raw)


On Sun, 21 Sep 2003 01:13:12 +1000, Sona wrote:

> it indents doSomething() to 4 spaces.. I need this to be 2 spaces only. 
> How can I do this? Thanks

I think you'll need to alter 'c-basic-offset' for this


Dave

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Customizing tab indentation width
@ 2003-09-20 15:13 Sona
  2003-09-20 14:52 ` Dave Footitt
  2003-09-22  8:51 ` Alan Mackenzie
  0 siblings, 2 replies; 3+ messages in thread
From: Sona @ 2003-09-20 15:13 UTC (permalink / raw)


Hi,

I want to set the default tab indetation width in emacs to be 2 spaces. 
I set this in the tab-with variable and also in the standard indent 
variable but it's not working. For example, if I type the following:

if (someVariable == true) {
     doSomething();
}

it indents doSomething() to 4 spaces.. I need this to be 2 spaces only. 
How can I do this? Thanks


Sona

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Customizing tab indentation width
  2003-09-20 15:13 Customizing tab indentation width Sona
  2003-09-20 14:52 ` Dave Footitt
@ 2003-09-22  8:51 ` Alan Mackenzie
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Mackenzie @ 2003-09-22  8:51 UTC (permalink / raw)


Sona <sona.gardner@nospam.net> wrote on Sun, 21 Sep 2003 01:13:12 +1000:
> Hi,

> I want to set the default tab indetation width in emacs to be 2 spaces.
> I set this in the tab-with variable and also in the standard indent
> variable but it's not working. For example, if I type the following:

> if (someVariable == true) {
>      doSomething();
> }

> it indents doSomething() to 4 spaces.. I need this to be 2 spaces only.
> How can I do this? Thanks

Which language mode are you talking about?  It looks like C or C++, so
I'll assume it's C.  If it's C++, make the appropriate alterations to
what follows.

The Emacs variable which controls the indentation is c-basic-offset, so
you need to set this to 2.  However, each time you open a new C Mode
buffer, the setup code sets a "buffer-local" copy of this variable to 4.

So you need to put this setting into a "hook function", this being a
function which gets run every time you open a new C Mode buffer.
Specifically, put something like the following into your .emacs:

(defun my-c-mode-hook ()
  (setq c-basic-offset 2))
(add-hook 'c-mode-hook 'my-c-mode-hook)

The first two of these lines define a function to do what you need.  The
last line puts in into a list of functions to call at setup time.

For further details, see the CC Mode info pages, in particular the pages
"Customizing Indentation" and "Permanent Customization".

> Sona

-- 
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").

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-09-22  8:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-09-20 15:13 Customizing tab indentation width Sona
2003-09-20 14:52 ` Dave Footitt
2003-09-22  8:51 ` Alan Mackenzie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).