I’m switching to VSCode but at this point all my sources are quite messed up and I manage to pinpoint what the problem is.
Basically when a tabulation char follows a word which is shorter than the editor.tabSize value VS will insert the amount of spaces in its settings minus the word length while it should probably insert the this value PLUS the editor value.
An example code rendered in Notepad:
Same code rendered by VSCode with editor.tabSize=4:
Every instruction is followed by ONE tab but VSCode requires TWO if tab follows a word shorter than tabSize.
Here tabs following "LEA" instructions end up being only one space long (tabSize minus length of word)
Is there a way to prevent this annoying behaviour? Changing all the occurencies in code would be quite a long work and they would be messed up when opened in other editors, surely not a solution.
Thanks!
2
Answers
Solved by increasing value of editor.tabSize to 10
https://github.com/microsoft/vscode/issues/201086
Contrary to what has been suggested in the comments by Timothy G., this is not a bug. This is normal behaviour.
VS Code aligns characters following tab characters to a grid based on the value of the
editor.tabSize
setting.Not really. That’s what you think it should do. But that’s not what the people who wrote VS Code thought it should do.
In fact, I would find the behaviour you are suggesting alarming, unless you want VS Code to detect multiple consecutive lines with non-leading tabs and perform columnar alignment for each positional non-leading tab character… Which is… a can of worms of its own. I mean… if you really want that, or some other behaviour, you can raise a feature-request.
Personally, with the current state of things (see above paragraph), I would suggest that if you’re really that picky about how tabstopping works, you should just switch to using space characters for spacing instead of tabs.
You could also switch to using spaces for non-leading runs of spacing, but that would also get messy if you have multiple consecutive lines where you want to use non-leading spacing to align intermediate contents of the lines, but where those lines do not all start with the same amount of indentation, in which case it will only work out for a specific display width of the leading tabs.
I think the workaround in the answer posted by the asker of this question is a poor workaround. It will affect leading indentation as well, and will only work when intermediate leading non-spacing-content is shorter than the specified tab width.
No, it does not actually insert spaces. When indentation is using tabs, it inserts a tab character and just displays the tab character with a certain width, aligning to a grid.