Forum > Editor

Using tabs instead of spaces with Lazarus

(1/4) > >>

Nadar:
Disclaimer: I know that there are many, in part strong, opinions regarding if tabs or spaces are the "best" form of indentation. I have discovered that it doesn't make much of a difference, it all depends on what you're used to (I used to be a space-indenter and have since converted after working a lot with code that is tab indented). What does matter though is that it is consistent, or formatting the code becomes somewhat "random".

I'm using Lazarus to write some code that is to be used in a project which uses tab as indentation. I've tried to configure it for using tabs to the best of my abilities, but it is inconsistent. My actual code ends up being a mix. It looks to me like the codetools (or something related) doesn't respect that tab is indentation.

As it is now, I have to manually "clean" the files before making git commits. It's a bit of a pain. I haven't found a way to actually show whitespace characters either, and the search/replace function is somewhat "hard to work with" (especially since it keeps closing every time you use it and you have to make sure the cursor isn't on something when opening it again, or it will replace whatever search phrase you were working on). So, I'm opening and formatting everything in another editor before committing. After that I have to make sure that the files are reloaded in Lazarus, so that the changes are kept. In, short, it's a hassle.

Is there a way to make Lazarus work properly with tabs, or do I have to keep doing this for every commit?

TRon:

--- Quote from: Nadar on December 07, 2023, 03:50:30 am ---Is there a way to make Lazarus work properly with tabs, or do I have to keep doing this for every commit?

--- End quote ---
As you wrote yourself each and everyone has its own opinion on tabs vs spaces but also choosing between either side each side seem to have its own preferences.

Though you ventilated your frustration on inconsistency you failed to mention what is inconsistent and what you already configured to try and make things work the way you want them to. I assume you are familiar with the menu Tools, options (IDE options), editor, general, items Tabs and indent & Miscellaneous ?

For example, at the misc item you can at least set the option "show special characters" that allows you to distinguish between tabs and characters.

Not saying that all these setting work in the way you want them to but in case you believe there is something that is not behaving as it should then you could always try and report it as a bug and/or feature request.

Thaddy:
The inconsistency is that tabs can not be relied upon.
I think that Lazarus has an option to treat tabs a a defined number of spaces. But I never used that since I am one of those guys that HATE tabs since I often need to reformat other people´ s code to make it readable..
I want consistent behavior along any editor I choose. Tabs do not fit that bill, although it should! it gives you more headaches than warranted.

Joanna from IRC:
Lazarus has an option to convert tabs to spaces as well as “ tab indents blocks” which I believe make the tab align with the previous line of code.

Thaddy:
That is what I suspected.

Navigation

[0] Message Index

[#] Next page

Go to full version