Inconsistent interpretation of tabs in the forum post editor

4 Ansichten (letzte 30 Tage)
DGM
DGM am 15 Jul. 2021
Kommentiert: Rik am 18 Mär. 2023
To preface, I don't even know if this problem can be replicated by others. Across various Firefox-based browsers, the post editor has other problems (can't use arrow keys, occasionally refuses to wrap lines, etc), so maybe it's just broken for me. I'm throwing this out there anyway.
When using the post editor, tabs are inconsistently interpreted. A tab entered via keyboard directly into the message body is interpreted as 4 spaces. We can all argue about spaces vs tabs, but either way, it's 4 characters wide. If I paste a tab from the IDE, it pastes as a single tab character, since I have my preferences to use tabs.
% examples
% tab entered via keyboard
% tab pasted from IDE
While the editor is still open, both tabs appear to be 4 characters wide, but once the post is submitted, the actual tab character in the second line appears as 8 characters wide. Whether it's some part of CSS or the editor, if the convention is that tabs are 4 characters wide, it should at least be consistent. If this is happening to other people, then it might explain why so many horribly indented code snippets appear.
So, does anyone else observe the behavior, and is there a workaround other than search+replace every time I post code?
  9 Kommentare
Stephen23
Stephen23 am 18 Mär. 2023
Bearbeitet: Stephen23 am 18 Mär. 2023
@DGM: snap! You are right, that is by definition the more natural choice :)
Rik
Rik am 18 Mär. 2023
I once followed an R programming course where the instructor argued for 8 spaces. His main reason was that you should have a very good reason to indent more than 2 levels, and 8 space indents together with an 80 character limit forces you to do something about deep indentation. I personally prefer 4 spaces with 100 characters width.
@dpb, you will be happy to learn that the default in GNU Octave is 2 spaces (although the editor is only a slightly tweaked Notepad++, so there are limits to what it can do).

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Historical Contests finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by