How many spaces do you indent?

2 vues (au cours des 30 derniers jours)
Chad Greene
Chad Greene le 26 Avr 2016
Just out of curiosity, how many spaces do you use when indenting code? I recently changed my settings from the default 4 to 3, and I think it's an improvement in readability and use of space.

Réponses (3)

John D'Errico
John D'Errico le 26 Avr 2016
Modifié(e) : John D'Errico le 26 Avr 2016
2 space indents for me. I think they charge extra for more spaces. And it takes so much more work for the computer to wade through all those extra spaces. :)
Seriously, I just think it is easier to read with shallow indents, especially if you have code with multiple levels of indentation. With big indents, things can start to run off the right side of the page.
Yes, it is true that too little white space makes code hard to read. But you can have too much too. I'll argue that 2 space indents are the choice Goldilocks would choose, were she a programmer.

Image Analyst
Image Analyst le 26 Avr 2016
I use 4.

Walter Roberson
Walter Roberson le 26 Avr 2016
When I write code by hand I prefer 2; that is what you will see on my postings. However, when I have not bothered to change the Preferences to use 2 instead of 4, so when I write in the editor and use Smart Indent I end up with 4.

Catégories

En savoir plus sur Data Import from MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by