Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrectly identation width detection for tab characters #1379

Closed
Akronix opened this issue Jan 27, 2017 · 8 comments
Closed

Incorrectly identation width detection for tab characters #1379

Akronix opened this issue Jan 27, 2017 · 8 comments

Comments

@Akronix
Copy link
Contributor

Akronix commented Jan 27, 2017

Hi.

I think I've been experiencing it 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.

@elextr
Copy link
Member

elextr commented Jan 27, 2017

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.

@Akronix
Copy link
Contributor Author

Akronix commented Jan 27, 2017

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?

@elextr
Copy link
Member

elextr commented Jan 27, 2017

A tab is a position, its not actually the "width" of a character, see Wikipedia. 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]

@Akronix
Copy link
Contributor Author

Akronix commented Jan 27, 2017

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 😅

@Akronix Akronix closed this as completed Jan 27, 2017
@elextr
Copy link
Member

elextr commented Jan 27, 2017

@Akronix what you don't want to be a subject of a Linus rant 😄

So just set your tab prefs everywhere (don't forget project) to 8 before you open any files and it should be ok.

@Akronix
Copy link
Contributor Author

Akronix commented Jan 27, 2017

haha definitely not @elextr. I'm reading the Linux Coding Style 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.

@elextr
Copy link
Member

elextr commented Jan 27, 2017

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 😄 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.

@b4n
Copy link
Member

b4n commented Jan 29, 2017

@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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants