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

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

Re: Substiotution of tabs with spaces...


From: Pascal Bourguignon
Subject: Re: Substiotution of tabs with spaces...
Date: 16 Apr 2005 01:38:46 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Peter Dyballa <Peter_Dyballa@Web.DE> writes:

> Am 15.04.2005 um 15:15 schrieb Pascal Bourguignon:
> 
> > Also, with my emacs configuration,
> > M-x replace-string RET TAB
> > tries to substitute a string of four spaces, not one tabulation.
> >
> > Try:
> >
> >  M-x replace-regexp RET C-q TAB + RET SPC SPC SPC RET
> >  M-x replace-string RET C-q TAB RET SPC SPC SPC RET
> >
> 
> Yes, that's something I've seen here too. I remember that I failed a
> few times to remove, i.e. replace-regexp with nothing, [SPC TAB]+$
> --  there could be a better regexp too. Do have an idea why TAB is
> sometimes \t and sometimes a few spaces?

TAB is TAB, and SPC is SPC.

What happens, is that TAB is a CONTROL character that was used to
CONTROL a mecanical teletype device, to make it move mecanically the
carriage to the next tabulation stop.

Since its meaning depends highly on the device (the width of the
tabulation changes, on some devices there's no tabulation, so it
doesn't show at all or is replaced by one space), and you cannot SEE
whether there is one TAB or several SPC, it should not be used in
normal files.  Use instead only SPC and sequences of SPC.

That's why in emacs, we usually bind the TAB key to more interesting
functions, such as lisp-indent-line or c-ident-command, and these
command indent the current line according to the syntax (using
normaly only spaces).

This has the added benefit that when you visualise the file in a
different environment, it always display correctly indented.


You should have: 
    (setq tab-always-indent t)
in  your ~/.emacs !

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.


reply via email to

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