One important thing you should know about:
If You working in a team, your codes will be shared in your team.
The most frustrating thing about this, if you don't use the same formatting rules, then your code will be harder to read to your teammate.
The simplest solution is to use a .editorconfig file in your project.
There are some options that you can read about at: http://editorconfig.org/
My .editorconfig file looks like this:
root = true
indentstyle = space
indentsize = 4
endofline = lf
charset = utf-8
trimtrailingwhitespace = true
insertfinalnewline = true
trimtrailingwhitespace = false