Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
baf02224a (master)
Description
The indentation settings in Qt Creator appear in different places - Text Editor -> Behavior, C++ -> Code Style, Qt Quick -> Code Style, and all of these can also be overridden in the project settings.
This confuses many users. For example, when they edit a js file (we don't use Qml at all), they're expected to discover that the indentation settings are in Qt Quick.
Moreover, a project can have different styles of indentation, so every time I save a file, I have to verify that I didn't break the indentation. For example, we indent with tabs in Qmake pro files, but shell scripts are indented with spaces (and some other shell scripts have tabs ).
I want to suggest a new "auto" mode (that should be the default IMO) for all these settings (Text, C++ and Qt Quick). In this mode, the indentation will be automatically detected, it will appear in the status bar, allowing the user to quickly change it (and possibly persist the setting by filename).
That's how indentation is configured in VS Code, and I find it very convenient.
Auto detection can be basic. You can find the first line that starts with either a space or a tab. If it's a space, count the spaces until the first non-space. Otherwise, the indentation is with tabs.
Advanced: The tab size can also be autodetected by heuristics. You can try finding a line that has tabs followed by spaces, and match it against the previous line. For example, if the previous line has an opening parenthesis and the text of the current line with the spaces can be aligned with this parenthesis, you can infer the tab size.
For example:
void func(int foo, <\t><\t> int bar);
We can determine that the tab size is probably 4.
And of course the user can always change this easily if the detection was wrong.
Attachments
Issue Links
- is duplicated by
-
QTCREATORBUG-31545 Auto detect indentation from content
- Closed
- relates to
-
QTCREATORBUG-31875 Project editor settings are ignored for certain files
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTCREATORBUG-25628 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
607097,11 | Editor: use detected indentation by default | master | qt-creator/qt-creator | Status: NEW | 0 | +1 |