sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
807 stars 39 forks source link

Detect tab indentation without any lines starting with tabs #4368

Open mortenfyhn opened 3 years ago

mortenfyhn commented 3 years ago

Problem description

I have some files of tab-separated data such as this: data

With

"detect_indentation": true`

these files open assuming spaces for indentation. To modify them--with tabs not spaces--I have to manually switch to tab indentation each time I open a file. Pasting between such files also converts tabs to spaces if I don't manually specify tab indentation.

The problem seems to be caused by the fact that no lines actually begin with tabs, they just contain tabs.

(For the curious: These are PX4 drone autopilot parameter files.)

Preferred solution

Automatically detect files like this as using tab indentation.

Alternatives

Maybe remember indentation settings for each file? That would solve 90 % of my problem.

Additional Information (optional)

Using Sublime Text 4107 on Ubuntu 18.04.

keith-hall commented 3 years ago

There's a difference between indentation and tab separation, just for reference, though ST currently doesn't distinguish them except in the case of opening files - it sees no indentation I guess and sticks with the default :)

In this case it seems like you are opening TSV files which by default open in the plain text syntax. One solution could be to use a dedicated syntax (bonus: you could get syntax highlighting for free) for these files, and set "translate_spaces_to_tabs": true, in your syntax specific settings. This would avoid the need for functionality like remembering the setting history based on file path (which could be achieved in a plugin btw)

mortenfyhn commented 3 years ago

There's a difference between indentation and tab separation, just for reference, though ST currently doesn't distinguish them except in the case of opening files - it sees no indentation I guess and sticks with the default :)

In this case it seems like you are opening TSV files which by default open in the plain text syntax. One solution could be to use a dedicated syntax (bonus: you could get syntax highlighting for free) for these files, and set "translate_spaces_to_tabs": true, in your syntax specific settings. This would avoid the need for functionality like remembering the setting history based on file path (which could be achieved in a plugin btw)

Yeah, you're right, this is separation rather than indentation. I'll look into defining a syntax! Thanks.