{"id":1061,"date":"2015-05-27T12:43:34","date_gmt":"2015-05-27T12:43:34","guid":{"rendered":"https:\/\/guwii.com\/?p=1061"},"modified":"2016-08-01T09:42:17","modified_gmt":"2016-08-01T08:42:17","slug":"tabs-vs-spaces-for-indentation-in-coding","status":"publish","type":"post","link":"https:\/\/guwii.com\/tabs-vs-spaces-for-indentation-in-coding\/","title":{"rendered":"Tabs Vs Spaces for indentation in Coding"},"content":{"rendered":"

This is one of the most trivial areas of coding that people argue over, often bringing up very nitty, and picky points as a point of reasoning.<\/p>\n

There is annoyingly, good reason to argue though. The indentation method you choose for your coding can have very surprising knock on effects in the future, so which one should you really use?<\/p>\n

And before you even start reading, if you currently have no preference or opinion<\/em>, I’m going to give you the answer.
\nFor coding indentation, you should use:<\/p>\n

Spaces – with 2 indents<\/h1>\n

Spaces with 2 indents are the go to answer that are generally most widely accepted and used, especially by big companies (Facebook \/ Stripe \/ Twitter API’s etc), so if you’re just starting out with coding, or have never even given it consideration before, 2 indented space’s are the go to method – this is the most commonly used setup, and unfortunately it’s better to just fit with the norm, unless you have strong opinions otherwise, but it’s generally these pointless arguments that just fragment the situation even further.
\nHowever, it’s important you use the same method as the rest of your development team (or try and get them to change ;)), consistency is the real best answer. So if that means using tabs, then so be it.<\/p>\n

But why?
\nThe way in which you indent your code may seem trivial, and for the most part it usually is. But it’s not until everything goes wrong that you really wished you had chosen the correct method and stuck with it.<\/p>\n

Not all operating systems, code editors\/IDE’s treat code indentation the same way. Tabs are the most common problem, some code editors will treat each tab indent as very small, where as others will treat it like a huge block. This leads to not all code indentation looking the same across multiple developers systems. With spaces you do not have this translation problem, a space, is always just 1 space.<\/p>\n

The reason most companies\/API’s\/libraries etc choose 2 indented spaces is:<\/p>\n