[Lazarus] Auto indentation

Graeme Geldenhuys graeme at mastermaths.co.za
Thu Nov 5 08:22:14 CET 2009


Martin wrote:
> If any commit converts tabs to spaces, then elastic tabs do not solve 
> any problem any more or less than any other tab handling does.

Correct. The true benefit of elastic tabstops is when you don't have to
do such conversions. Simply switch your source code to only using tab
characters for indentation and a Elastic Tabstop enabled editor will do
the rest for you - no matter what the users tabwidth preference is set at.

The conversion from Tabs to Spaces when using a elastic tabstops enabled
editor is simply as a stop-gap or for backward compatibility with users
that don't have elastic tabstops enabled editors.

Personally, I would switch immediately to using tabs instead of spaces.
In standard editors like Lazarus IDE, I prefer a default tab width of 3
characters, but I don't use tabs in my code simply because I work on
various projects with other developers. A sad compromise - I know.

Maybe later when Jedi Code Formatter works correctly in Lazarus, all
source code will look consistent. eg: You write your add-on / patch for
Lazarus in your favourite coding style. The just before you generate a
patch you press Ctrl+D and the code is formatting as per the Lazarus
project standards, then generate the patch. But that wouldn't work in
all cases either. :-(

> Such conversion (to spaces / from spaces) can be applied to any form of 
> tabs that you have in your source code

No true. Most editors have a single value for a tab to space conversion.
eg: 1 Tab character = 4 spaces. Elastic tabstops conversion from tabs
to spaces doesn't do that. It's a bit more intelligent. I looks at the
surrounding code to see how things are aligned using tabs, then inserts
variable amount of spaces so that alignment of the content stays the
same after the conversion.

I'm not 100% sure how the conversion from Spaces to Tabs word. But if I
had to use Elastic Tabstops, I would switch my projects to using tabs
only - so no conversions or guesswork is required.

Plus, have you seen how much smaller source code files become if you
user tabs instead of spaces. Also elastic tabstop enabled editors use
even less tab characters than normal editors. The size difference is
actually quite big (I was even surprised).


Regards,
  - Graeme -

-- 
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/





More information about the Lazarus mailing list