-1

A very new coder here! What is the difference of using tabs and spaces in visual appearance. I understand that tabs can have a different length of columns, and how they look, but what about indentation with spaces? How does it work? Do developers indent code with only 1 space or with several or more spaces?

Noah
  • 1
  • In experience on stackoverflow, android studio, notepad++ when you want intent your you need to put 4 spaces so this can equals to tab but this can change. – Crammeur Aug 03 '18 at 08:30

2 Answers2

0

Tabs

Now, of course, consistency matters more than either one, and a good IDE makes the differences negligible. That said, the point of this thread is to be a holy war, so:

I prefer tabs:

They're a character specifically meant for indentation They allow developers with different preferences in indentation size to change how it's the code looks without changing the code (separation of data and presentation for the proverbial win!) It's impossible to half-indent something with tabs. So when you copy code from some website that used 3 spaces into your 4-space indented file, you don't have to deal with misalignment.

Spaces

A tab could be a different number of columns depending on your environment, but a space is always one column.

In terms of how many spaces (or tabs) constitutes indentation, it's more important to be consistent throughout your code than to use any specific tab stop value.

AlexiAmni
  • 382
  • 1
  • 15
0

If you are using Microsoft visual studio it will be formatted by the IDE. In Visual basic it is done automatic, in C# and others you need to press Control-K D to format the document. Actually the IDE is using spaces to format the document.

Wilhelm
  • 196
  • 10