Tab vs. spaces, for code indentation [closed]

0

Is there a recommendation on what is most appropriate? Tab character ( \t ) or spaces?

From what I can see, you usually have conventions by language:

  • Ruby : two spaces
  • Delphi : two spaces
  • Python : four spaces
  • Java : tab
  • etc

In the case of Python we have a particularity, the indentation is taken into account by the compiler, but it is smart to recognize both spaces and tabs.

    
asked by anonymous 24.07.2014 / 13:04

1 answer

1

I do not know a standard recommendation for indentation. Every language uses yours.

What I usually practice is to follow the convention of each language. In general it is more common to use spaces than tabs.

What has always been a good practice for me is at the beginning of a project, involving more than one developer, always writing a code standards document that not only defines indentation, but also names used in variables, methods, where use camelCase, where to use PascalCase, etc.

The first rule of this document is: for any situation that does not have something combined, combine.

It always worked for me to work that way.

    
24.07.2014 / 13:47