3 ms·
I just tried enabling that this week, but I found that I often press Ctrl-S out of habit, even when I have syntactically invalid code and then the autoformatter
by rolisz 5y ago
I just tried enabling that this week, but I found that I often press Ctrl-S out of habit, even when I have syntactically invalid code and then the autoformatter messes things up royally and I get lost. For now, I just memorized the shortcut for autoformatting and I'm running it manually when I feel the need to "tidy up" the code.
- Waterluvian 5y agoI’m curious what language you’re working on and what formatter it uses? In my experience many formatters will not run if the AST is invalid.
- rolisz 5y agoI'm using Python and PyCharm. It happily underlines the invalid syntax and then reformats things more or less randomly.
- goodells 5y agoMine won't do any auto-formatting when the syntax is invalid, so when I hit CMD + S and it _doesn't_ format it's a cue to start looking for errors.
- Waterluvian 5y agoThe only issue I have with this is that I wish it would chirp more loudly when there's a syntax error. Every so often I don't notice red underline and I begin wondering why my autoformatter and autocomplete aren't working anymore. Maybe a red border or something any time a file's syntax is invalid.
- trevyn 5y agoI’m a big fan of Error Lens.
- randomluck040 5y agoThere is a package called „black“ (pip install black) that formats code according to PEP8 (most of the time). You might take a look if you’re interested. I’m using it occasionally and it didn’t do anything royally stupid until now. If the code isn’t syntactically correct it won’t run.