Hi.
I think I've been experiencing for quite some time now.
I always have set the option of "Detect width from file", but Geany seems to always set my tab width as 2 (I have set 2 as width in chars of a single indent), no matter the width that is already in the file.
For instance, let's say I open a 8-width tabs file: Geany displays the indentations as two-width, but I expected them to be eight-width. I'm talking about files with tab characters for indentation. No sure about files with whitespaces.
Its not possible to detect a "width" for tabs, it only has any chance of working for spaces. So files with tabs just use the indent width you have set in preferences or project.
I'm curious about this: is the tab character width defined in every file or it's rather a matter of how the editor/program displays it?
A tab is a position, its not actually the "width" of a character, see [Wikipedia](https://en.wikipedia.org/wiki/Tab_key). There is a computer convention that these positions be multiples of 8 ASCII spaces from back in the pre-unicode pre-web forms days. The character just says "go to the next tab position".
So its completely a function of how its displayed.
Some editors allow specially formatted comments in files to define the tab position for files of some languages but thats not available in Geany. It may be accepted if a well written pull request was proposed.
[WARNING personal rant]
But as it notes in the Wikipedia article, tabs are an artefact that mainly helped reduce the size of source files back when disks were 300k bytes. But we are not so disk starved that we should care today. All tabs in source files should be replaced with spaces. If you are starting a new project set your indents to spaces and have tab insert spaces. Tabs in source files should die!!!
[end personal rant]
Closed #1379.
Ok, thank you @elextr for the explanation. I'm playing with the Linux kernel, so I don't feel like I'm on a position to replace tabs with spaces :sweat_smile:
@Akronix what you don't want to be a subject of a Linus rant :smile:
So just set your tab prefs everywhere (don't forget project) to 8 before you open any files and it should be ok.
haha definitely not @elextr. I'm reading the [Linux Coding Style](https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/plain/D...) and I feel that breaching a rule is like breaching a sacred Commandment.
By the way, I've noticed that it's not enough to reload the file after re-setting the tab width, but I have to actually close and open it again.
By the way, I've noticed that it's not enough to reload the file after re-setting the tab width, but I have to actually close and open it again.
Well, I DID say before you open any files :smile: but if you insist in changing the prefs setting with files open you better read the italic and the other note at the top of the indentation prefs window.
@Akronix you can set indentation width specific to one single file in *Document -> Set indent width*, hence changing the setting is not overriding file's :)
github-comments@lists.geany.org