Hacker News new | past | comments | ask | show | jobs | submit login

The automatically inserted whitespace always bothered me in VS Code. When writing code without an auto-formatter I always end up noticing the extra whitespace in the diff before committing and end up hunting it down. Automatically trimming the automatically inserted whitespace sounds like a somewhat complicated solution. It makes me wonder how other editors handle this, because I never had this problem with other editors.



Could you expand on why you don't like to use an auto-formatter? I'm genuinely curious.

I'm pretty addicted to them; they add consistency without me having to think about it (killing off bike-shedding in the process), and in practice it works a bit like a visual semi-linter: if the auto-formatting doesn't produce the expected pattern (and your mind very quickly picks up the pattern subconsciously), it usually means there's a bug in the code somewhere around the area where it goes wrong.


I do like to use auto-formatters, but sometimes they are not available. For instance, until recently I didn't have anything for rust-lang. But rustfmt is pretty good now and VS code has good support for rust-lang through the RustyCode extension.


I use kate (KDE Advanced Text Editor) and there's a setting that removes trailing whitespace whenever you save a file. Works awesome.

You get auto-indent and at the same time don't have to worry about leftover whitespace everywhere when you 'git commit'. In fact, after accepting pull requests I'll often just open up the files in kate and doing a trivial edit + save to ensure there's no pointless whitespace.


The IntelliJ family of editors will automatically put the caret at the right indent level wherever you are in the file, but leave the line empty of whitespace unless you actually type something on that line. That makes a lot more sense to me.


F1 then type trim. The first option to pop up should be the trim whitespace command. Hit enter. Or there is an option to trim automatically on save.


They do have a setting to automatically remove whitespace "files.trimTrailingWhitespace": true

Or I don't understand what you are talking about ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: