Editor Config ( editorconfig.org ) is one of the first files I check into a repo and is there to make sure that everything is done consistently between all editors - IntelliJ, Notepad++, VS Code…
Comment on Tabs are objectively better than spaces - gomakethings.com
stevecrox@kbin.social 1 year ago
Years ago there was no way to share IDE settings between developers.
You ended up with some developers choosing a tab width of 2 spaces, some choosing 4 spaces and as there was no linting enforcement some people using 2-4 spaces depending on their IDE settings.
This resulted in an unreadable mess as stuff was idented to all sorts of random levels.
It doesn't matter if you use tabs or spaces as long as only one type is consistently used within a project.
Spaces tends to win because inevitably there are times you need to use spaces and so its difficult to ensure a project only uses tabs for identation.
IDE's support converting tabs into spaces based on tab width and code formatting will ensure correct indentation. You can now have centralised IDE settings so everyone gets the same setup.
Honestly 99% of people don't care about formatting (they only care when consistency isn't enforced and code is hard to read), there is always one person who wants a 60 charracter line width or only tabs or double new lined parathensis.
shagie@programming.dev 1 year ago
FlagonOfMe@sh.itjust.works 1 year ago
When? You indent with tabs then add any spaces you want for precise alignment. When would you need to use spaces to indent?
stevecrox@kbin.social 1 year ago
Parameter declarations, array initialisation and lambda alignment is the most common.
Java Lambda expressions can be hundreds of characters long so wrap on to the next line. A lot of code formatters will auto wrap with a single identation.
A lot of developers instead like to align each lambda call with the one above. They feel its more readable, personally I agree.
Normally in DevSecOps I offer a standard code format to a team, I highlight the contentious choices (like spaces or tabs) and ask the team if they have strong feelings about it and then sit back and let them decide.
My only thing is ensuring you don't mix tabs and spaces.
BatmanAoD@programming.dev 1 year ago
What did you mean by “inevitably there are times when you need to use spaces”, then?