code
code copied to clipboard
Automatically remove trailing spaces after pressing Enter
Feature request: Like Visual Studio, it would be awesome if Code could satisfy my OCD by clearing spacing (and tabs) from empty lines, i.e. lines with no text in them. The company I work for has made it part of their coding standards that blank lines should be completely blank, including any excess spacing.
Enable the plugin Strip trailing whitespace
from the preferences dialog. It does exactly that.
Ah now I feel slightly foolish... except am I right that this only works when manually saving? I'd like for trailing spaces to be stripped in real-time if that's possible.
yeah you are right. Title can me made a little clearer. Anyway someone needs to just call it on enter key press event instead of save event and submit a new plugin. Is this how vscode handles it? Does it remove the whitespaces from whole file or just the current line?
I think as you type, Visual Studio (not sure about VS Code) removes trailing spaces from the current line after hitting enter/return.
If stripping is enabled for automatic save then it should not be applied to the line being typed.
This could be annoying as I often temporarily move away from the current line which might contain space (tabs) which I do not want removed at that point as I want to paste something afterwards. You can force stripping just by pressing <Ctrl>S
if you want. You should always check for trailing space before committing anyway using the linter io.elementary.vala-lint