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

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

Re: c-mode tab is not tabbing


From: Alan Mackenzie
Subject: Re: c-mode tab is not tabbing
Date: Sat, 7 Feb 2009 15:42:56 +0000
User-agent: Mutt/1.5.9i

Hi!

On Thu, Feb 05, 2009 at 01:55:31PM -0800, rubing wrote:

> If i press the tab key in the body of the text in order to write a
> comment or such it does not work.

What do you mean by "in order to"?

In Emacs mostly, and definitely in CC Mode, TAB indents the current line
according to its syntax.  So, if you had this

main ()
{
printf ("Hello, Emacs!") ;
}

, and typed TAB on the the long line, it would indent it 4 spaces.
(Actually, typing that last ";" will have triggered automatic
indentation.)

If you want to insert an actual ASCII Tab character, the way to do this
is C-q Tab (that's hold down the control key, press q, leave the control
key, press TAB).  You probably don't "want" to do this, however.

To insert a comment at the end of the current line, you could go there
and type "/* .... */".  Better, just type M-; (that is, whilst holding
down the "meta" (alt) key, type ";").

> The tab key only works at the beginning of the line for only as many
> tabs as proper formatting allows.

There are lots of different values of "proper".  :-)  I'm guessing that
you want the indentation to be done with tabs rather than spaces, as far
as possible.  For this, "customize" `indent-tab-mode' by clicking the
pertinent menu entry, or by typing M-x customize-variable<CR>.

> I want to be able to use tab anywhere.  How can I change this??

You mean, I think, you want pressing the tab key to insert a tab
character (ASCII 9) into your buffer.  First comment, you're probably
mistaken about this.  ;-)  You probably _don't_ want to "use" the tab
key this way (see below).  However, if you did, the way would be to
"bind" the key to the `self-insert-command' command, by writing this into
your .emacs file (that's your primary initialisation file.  If you
haven't got one yet, create it with C-x C-f, then type in "~/.emacs" (no,
don't type the double quote marks)):

    (define-key c-mode-base-map "\C-i" 'self-insert-command)

(don't forget the tick).

However, if you do this, you'll lose the indentation feature of the tab
key.  Question, why do you want to type TABs?

-- 
Alan Mackenzie (Nuremberg, Germany).




reply via email to

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