When formatting or typing the input data or expression, there can be a mix of tabs and spaces used for indentation. This causes some formatting issues when pasting example data/expressions into other online sites like Slack, Stack Overflow, and Google groups. Would it be difficult to always use 2 spaces when auto-indenting, or even when typing a tab to manually indent?
The textareas in the exerciser page provide intelligent code handling via the codemirror
npm module. According to the online docs, keys like tab can be mapped to a function, like so:
Common example: map the Tab key to insert spaces instead of a tab character.
editor.setOption("extraKeys", {
Tab: function(cm) {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
cm.replaceSelection(spaces);
}
});
The goal (for me) is to ensure that all 3 textareas do not contain any tab characters. But in general, more consistent indentation handling would be a nice enhancement as well. For instance, in most IDEs (and the ACE editor) hitting the tab key anywhere in front of a line of code causes it to increase indention levels -- while hitting shifttab decreases the indention level. The current exerciser site does not work this way.
The example code above implies that if several lines were selected, they would be replaced by spaces. Obviously, this is not a desirable behavior. Instead, each of the selected lines should be indented one more level -- probably a much more involved piece of code. I'll see if I can find examples of indenting multiple lines, and add them to this issue.