Editor Tab Expansion

C.Reinke C.Reinke@ukc.ac.uk
Thu, 05 Dec 2002 19:07:13 +0000


> Having more than 10 years expirience with "whitespace does not
> matter" languages, the only thing that drives me crazy is the
> layout rule.

so in 10 years of programming, you've never written a Makefile?-)

> As far as I understand it, I have 2 options:
> 
> 1. Use braces and semicolons and ignore the layout rules.
> 
> 2. Change the settings in all my editors so that the code looks
>    like the Haskell compiler sees it. 

3. Change the settings in all your editors to get rid of those
   crazy hard-tabs!

Good editors support this by enabling you to replace hard-tabs by
soft-tabs (you type <Tab>, your editor inserts the right number of
spaces, for a configurable notion of "right" => you can keep your
favourite tab2space number and you and the compiler see the same code).

(e.g., in Vim, type ":help tabstop" for a discussion of
 alternatives, my personal favourite is

  2. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use
     'expandtab'.  This way you will always insert spaces.  The
     formatting will never be messed up when 'tabstop' is changed.

 you can still enter hard tabs when needed, e.g., in Makefiles,
 using CTRL-V <Tab>; there's also a useful help to make hard-tabs
 visible for debugging - ":help 'list'").

I got into the habit of hating hard-tabs before learning Haskell -
in multi-developer projects, different layout styles are one thing,
but combined with hard-tabs and different tab2space settings..

Hth,
Claus