Auto format default style

Using “Ctrl + S” on replit editor formats the code to some default style (probably closer to K&R). Can we have a User setting to set this to some custom formatting defined by the user, say Allman style?

I’m not sure if this feature exists already, if it does, feel free to point this out!

Appreciate your help. Thanks

3 Likes

I don’t think it exists.

3 Likes

Would be great if we could use prettier to format. It is possible to set it to watch for changes in a repl, but due to how repls are saved it randomly formats as you’re typing (which isn’t the best experience)

There is an unofficial Prettier extension. You can go to the Extensions tool in the workspace, type “Prettier”, then install the first one.

2 Likes

That shouldn’t be happening, are you using Ctrl+S to try to save your repl? If so, that doesn’t save, and is a keybind for the formatter.

2 Likes

hey sorry for the delay, sorry no with the extension it only formats when you press to format but sadly not on Ctrl+S like it would in a local environment. If you run prettier in watch mode though it randomly reformats due to the fact that Repls are automatically periodically saved. Basically there isn’t a good option without allowing us to choose a command to run on Ctrl+S instead of the default formatter

Correction: When I say good I mean in my opinion, I personally like how Prettier runs locally (format on save), I dislike the extension as I have to select to format and I dislike running watch mode inside a Repl as it auto saves (and therefore randomly formats)