(Split off from Automatic Backup Plugin)
There’s no reason a plugin couldn’t be created that set the tabSize and translateTabsToSpaces settings via onLoad. It’s pretty simple to do a reasonably good job at detecting indentation settings:
- Grab the first couple of hundred of lines from the file (Need to do enough so that long header comments don’t break things, and not so many that it keels over on million line log files)
- Remove all the lines that start with no white space or only a single space
- Of the remaining lines (assuming there are enough to make a valid attempt, say > 10):
- If the majority start with a tab, set translateTabsToSpaces to be true
- Otherwise, set the tabSize to the highest value such that 90% of the lines have the property numberOfLeadingSpaces % tabSize == 0