C
C#2y ago
ezoll

✅ How can I make VSCode auto add semicolons to statements on save?

I'm coming from the world of Javascript and Typescript. There, you can just use Prettier to automatically add semicolons. I don't like having to manually add a semicolon to every statement. Can I automatically have semicolons added to statements on save in VSCode?
5 Replies
reflectronic
reflectronic2y ago
no, there is nothing that does that semicolons are not optional in C#, which makes it not very easy to do. the formatter would be guessing where they go. you can come up with many instances where it's not clear where the semicolon should be inserted in TypeScript the code has meaning even without semicolons, it's just a formatting choice, so it's something a formatter can reasonably claim to do correctly
Aaron
Aaron2y ago
you'd get errors all the time while writing, which would make for a pretty bad experience
jcotton42
jcotton422y ago
with enough time it'll just become a habit I can't remember the last time I forgot to add one
Landan
Landan2y ago
Imagine hitting enter, and if the end of the line lacks a semicolon, it deletes the line 💀 Ooh ooh, unterminated lines should be a certain tinge of color!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server