by tmm · 4y ago · 0 comments
Then I started using code formatters, initially `indent', then vim plugins. Eventually, I found myself using Visual Studio professionally, and became content letting the IDE decide how code should be formatted. Now, I do whatever the language/community seems to prefer. For .NET stuff, Visual Studio defaults; Go and Rust have their own formatters, RubyMine defaults for Ruby, etc.
Everywhere I've worked whenever the code formatting debate comes up, "use the IDE/compiler/community standard" always wins the day. The hardest thing seems to be convincing Windows users that text files need to end with a newline. Is there a git option (like `autocrlf') for that?
It's a lifesaver when you care more about formatting than any of your coworkers and can set up something that handles it for them.
Additionally, configuring editors/IDEs to format code when the file is saved is very useful to enforce formatting rules.
In the end it doesn't matter what's my preferred way of indenting code, the hardest part is always making people agree on it. So whenever a new project starts and the team needs to define code styling, we go with the language/IDE defaults. Anything else requires IDE setup and attention to indentation, which is too much to ask for when people barely pay attention to code quality.
gofmt does this.
> use the IDE/compiler/community standard
gofmt does this too :-)