Sublime Forum

Indentation autodetection doesn't work for files in command line

#1

If I start sublime with a filename in the command line (e.g. “subl file.cpp &”), sublime doesn’t seem to detect indentation style (tabs vs. spaces) that is used in the file. In my particular case the file is a C++ source file which uses tabs for indentation and sublime selects spaces, as can be seen in View -> Indentation.

The problem is present only when you start sublime (which is not already running) with a file in the command line. If you open the file from within sublime (via File -> Open), autodetection works. I have tested that it works with the very same file that doesn’t work in the command line.

I have “detect_indentation”: true and “use_tab_stops”: true in the default Preferences.sublime-settings and these parameters are not present in user’s Preferences.sublime-settings. Sublime version 3.1.1 build 3176. Kubuntu 18.10 x86_64.

0 Likes

#2

I guess its because the indentation detection is implemented in a plugin, which is loaded after the file is loaded, so it doesn’t receive the on_load_async hook for the file

1 Like

#3

Can this be fixed, e.g. by loading the file after all plugins are loaded?

0 Likes

#4

As a workaround you could wrap the subl call in a script that checks whether a sublime_text process is running already and otherwise launches it first, waits for a while and then opens the file with it.
There isn’t really another way currently, I’m afraid.

0 Likes

#5

Thanks. I understand a workaround is possible with a script, but I’m really interested in a fix in sublime itself.

0 Likes

#6

The problem is still present in version 3.2.1 build 3207.

0 Likes