From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.help Subject: Re: Customizing tab indentation width Date: Mon, 22 Sep 2003 08:51:35 +0000 Organization: muc.de e.V. -- private internet access Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <3f6c6c5f$1@clarion.carno.net.au> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1064263573 4762 80.91.224.253 (22 Sep 2003 20:46:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 22 Sep 2003 20:46:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Sep 22 22:46:12 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A1XZT-0002FS-00 for ; Mon, 22 Sep 2003 22:46:11 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.22) id 1A1XZT-00034o-1R for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Sep 2003 16:46:11 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!logbridge.uoregon.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!news0.de.colt.net!newsfeed.r-kom.de!news.m-online.net!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 43 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1064262661 54790 193.149.49.134 (22 Sep 2003 20:31:01 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 22 Sep 2003 20:31:01 GMT User-Agent: tin/1.4.5-20010409 ("One More Nightmare") (UNIX) (Linux/2.0.35 (i686)) Original-Xref: shelby.stanford.edu gnu.emacs.help:116798 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:12723 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:12723 Sona 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").