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: replace TAB with 8 whitespaces Date: Thu, 12 Jun 2003 17:26:53 +0000 Organization: muc.de e.V. -- private internet access Sender: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: main.gmane.org X-Trace: main.gmane.org 1055487340 27416 80.91.224.249 (13 Jun 2003 06:55:40 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 13 Jun 2003 06:55:40 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 13 08:55:36 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19QiS4-00074F-00 for ; Fri, 13 Jun 2003 08:54:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19QiT7-0004Zf-CB for gnu-help-gnu-emacs@m.gmane.org; Fri, 13 Jun 2003 02:55:25 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!cyclone.bc.net!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.space.net!news.muc.de!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 47 Original-NNTP-Posting-Host: acm.muc.de Original-X-Trace: marvin.muc.de 1055486411 36332 193.149.49.134 (13 Jun 2003 06:40:11 GMT) Original-X-Complaints-To: news-admin@muc.de Original-NNTP-Posting-Date: 13 Jun 2003 06:40:11 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:114421 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1b5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Help: List-Post: List-Subscribe: , List-Archive: List-Unsubscribe: , Errors-To: help-gnu-emacs-bounces+gnu-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:10914 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:10914 jinneemop wrote on Fri, 13 Jun 2003 00:49:21 +0800: > Hi all, > I wish to use 8 spaces to indent source code under c++ mode. > When I press TAB, I'd like emacs to insert 8 spaces instead. > How can I do this? Finding the correct place in the Emacs info pages is the first challenge. This can be done by: C-h i m emacs m indentation Then read through to the bit about "Just Spaces", which is exactly what you're asking about. Unfortunately, there are several ways to "solve" your problem, so here's what's going on. You need to set the variable indent-tabs-mode to nil. This variable is buffer-local, which means if you just set it, that setting only applies to the current buffer. If you are happy about always using spaces for indentation (e.g. for other modes) you can change the default value of this variable by putting this early on in your .emacs: (setq-default indent-tabs-mode nil) This is what I do. If you just want this thing for c++ files, set the variable in the c++-mode-hook, like this: (defun my-nospaces () (setq indent-tabs-mode nil)) (add-hook 'c++-mode-hook 'my-nospaces) If you want a middle position, i.e. also using spaces in C Mode, Java Mode, ... (all constituent modes of CC Mode), add the function to the c-mode-common-hook instead of the c++-mode-hook, like this (add-hook 'c-mode-common-hook 'my-nospaces) All the best! -- 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").