Currently, Qlik Sense's browser-based script editor handles indentation by inserting a frustrating mix of spaces and tabs:
- If no text is selected, pressing tab inserts a 4-space-wide tab at the cursor.
- If any text is selected, pressing tab indents the relevant line(s) by 2 spaces and converts tabs to spaces.
- If no text is selected, pressing shift-tab removes 100% of the indentation from the current line.
- If any text is selected, pressing shift-tab unindents the related line(s) by 2 spaces.
- Pressing backspace deletes 1 character (rather than deleting 1 indentation level's worth of spaces when appropriate).
- Pressing enter at the end of a line causes the newly inserted line to be auto-indented to the same level, which is good. But if the original line was indented with tabs, the new line will be indented with an equivalent number of spaces.
- When the "comment/uncomment" button is pressed, leading tabs are converted to spaces, and if you had selected both lines with tabs and lines with spaces that were visually aligned to start, they won't be aligned as comments. When you press the button again to uncomment the code, it will be restored to how it was originally, but not if you edited it while it was commented to make the comment look ok.
- If you use Qlik's editor exclusively, you will probably end up with a mix of tabs and spaces, and it's a burden to work with. The only easy way to clean it up is to paste it into a real text editor that can convert between the two (e.g. Sublime).
Proposal:
- Please settle on either spaces or tabs rather than mixing the two.
- You could add user preferences for tabs vs spaces and for indentation width, but that's of secondary importance. The main need is for tab, shift-tab, backspace, enter, and the comment/uncomment button to work together in a cohesive way.
- Ideally, when code is copied and pasted into the editor, the indentation should be standardized as well, or there could be a manual indentation-fixing button. But this is just the cherry on top and should not hold back progress either. This is because it's reasonable to hold users responsible for code they paste in, whereas Qlik is mostly responsible for the tab/space mess generated by their editor.
I'm not sure whether these behaviors vary depending on the browser, but I am using Chrome.