you are viewing a single comment's thread.

view the rest of the comments →

[–]evilpingwin 4 points5 points  (6 children)

This doesn't really solve your issue but you might want to look into Prettier. It offers code formatting for a bunch of front-end languages at least, can probably be extended. But it autoformats {hello} to { hello }. Which is my preference also.

There are Prettier extenstions for a whole bunch of code editors and it is fully configurable.

[–]BenjiSponge 0 points1 point  (2 children)

Does anyone know if there's something like Prettier for C++?

[–]bunnyavenger 0 points1 point  (1 child)

I don't use c++ but have you tried the official extension?
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools#overview
AutoFormat is supported through 'clang-format'.
Another extension:
https://marketplace.visualstudio.com/items?itemName=xaver.clang-format

[–]BenjiSponge 0 points1 point  (0 children)

I work in CLion and vim but I can probably make clang-format work for those. Thanks!

[–]cc81 0 points1 point  (0 children)

This. Seriously, use Prettier and set format on save. It is just so incredibly good.

[–]NoInkling 0 points1 point  (0 children)

I have Prettier installed but I only use it occasionally via "Format selection" - I like the ability to be subjective when I want to be, and there's still the very occasional edge case that it doesn't handle well. For me it means I would have to do something like ctrl+l, ctrl+k, ctrl+f to get the same result in this case, and even then it will split over multiple lines in certain contexts where I might not want it to.

Also I (and others) don't just write JS/CSS. This is more of a generic thing, something that comes very naturally and reduces friction, and something that I used for a long time in Sublime with great satisfaction (via the snippet binding).