This Sublime Text 3 plugin automatically detects and sets the indentation for you, by default, when a file is loaded.
As of Sublime Text 4, the dev team has been use test cases from this plugin to improve the built-in indentation detection and it works quite well. So, you probably no longer needs this plugin in Sublime Text 4.
Sublime Text detects the indentation when a file is loaded
if detect_indentation
is set to true
, which is the default settings.
However, its detection is wrong sometimes. You could give following cases a try!
- Files under the problem_files/
- https://forum.sublimetext.com/t/detect-indentation-with-3-spaces-is-broken/45143
- sublimehq/sublime_text#1459
- sublimehq/sublime_text#1640
I find that Indent Finder detects above files correctly so I make it into this plugin.
-
Abbreviations
- ST = Sublime Text
- ASI = AutoSetIndentation (this plugin)
-
ASI respects indentation settings from
.editorconfig
files. -
If you don't want to replace ST's
detect_indentation
command with ASI's, set the plugin settinghijack_st_detect_indentation
tofalse
. -
Even if
hijack_st_detect_indentation
is set totrue
by default, ST will still detects the indentation internally before ASI is ready to work. After that, ASI will detects the indentation again hence ST's result will be overridden but the detection is done twice. Therefore, you may want to setdetect_indentation
tofalse
to skip ST's.
This package is available on Package Control by the name of AutoSetIndentation.
To edit settings, go to Preferences
» Package Settings
» AutoSetIndentation
» Settings
.
I think the settings file is self-explanatory. But if you still have questions, feel free to open an issue.
You may disable all event_listeners
in your user settings
and add a key binding to auto set the indentation whenever you want.
{ "keys": ["ctrl+alt+s", "ctrl+alt+i"], "command": "auto_set_indentation" },