all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie<none@example.invalid>
Subject: Re: replace TAB with 8 whitespaces
Date: Thu, 12 Jun 2003 17:26:53 +0000	[thread overview]
Message-ID: <t4dacb.r5.ln@acm.acm> (raw)
In-Reply-To: pan.2003.06.12.16.48.50.728916@isee.zju.edu

jinneemop <jinneemop@isee.zju.edu> 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").

  parent reply	other threads:[~2003-06-12 17:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-12 16:49 replace TAB with 8 whitespaces jinneemop
2003-06-12 17:19 ` Henrik Enberg
2003-06-12 17:26 ` Alan Mackenzie [this message]
2003-06-12 17:34 ` Peter J. Acklam
2003-06-13  7:00 ` Kai Großjohann
2003-06-16 12:51   ` jinneemop
2003-06-16  7:26     ` Kai Großjohann
2003-06-16 19:52       ` jinneemop
2003-06-16 12:36         ` Minibuffer and Dabbrev problems K T Ligesh
2003-06-16 13:17         ` replace TAB with 8 whitespaces Kai Großjohann
2003-06-16 13:53         ` Stefan Monnier
     [not found]         ` <mailman.7972.1055767014.21513.help-gnu-emacs@gnu.org>
2003-06-16 15:11           ` Minibuffer and Dabbrev problems Kai Großjohann
2003-06-16 17:25             ` Johan Bockgård
2003-06-16 23:02               ` K T Ligesh
2003-06-17 17:39           ` Kevin Rodgers
2003-06-18 12:11             ` K T Ligesh
     [not found]             ` <mailman.8150.1055940540.21513.help-gnu-emacs@gnu.org>
2003-06-18 16:33               ` Kai Großjohann
2003-06-18 19:29                 ` Stefan Monnier
2003-06-18 23:30               ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=t4dacb.r5.ln@acm.acm \
    --to=none@example.invalid \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.