I want to start a focused discussion about indentation in Motoko formatting tools.
Currently, there is no consistent practice across projects.
Some use 2 spaces, some use 4 spaces.
This happens because the VSCode Motoko extension picks up the editor’s default indentation (often 4 spaces), while the Motoko style guide and base library use 2 spaces.
Another data point: the mo-fmt CLI tool uses prettier-plugin-motoko (also used by the VSCode plugin) internally and always formats with 2 spaces, with no option to choose 4 spaces.
I personally don’t mind whether it’s 2, 4, or 7 spaces, but I think it would be much better if formatting was consistent across the ecosystem.
Should the Prettier plugin enforce 2 spaces by default (in line with the style guide and mo-fmt) so all codebases end up with the same indentation automatically?
I’d like to hear your thoughts so we can hopefully agree on a path forward and avoid this ongoing inconsistency.
Thank you for bringing this up! I opened this PR to change the built-in VS Code formatter to use 2 spaces by default, which seems like a reasonable solution.
It’s already possible to override the default indentation by creating a .prettierrc file and specifying tabWidth (or even useTabs if preferred).