|
Hello fellow Computer Scientists/Programmers!
I was curious about the indenting style most people use. I have used 4 spaces for a long time, because I like how clear it makes things. If lines start to get too long with 4 spaces, I feel like you have bigger concerns than your indentation width .
Recently I started programming in Erlang using code written by another developer as an example. I noticed he liked to code with 2 spaces, which I don't think is enough personally. How much do you guys indent?
Poll: How many spaces do you indent?4 (50) 59% 2 (20) 24% 5 (5) 6% 3 (4) 5% 1 (3) 4% 8 (2) 2% 7 (1) 1% 6 (0) 0% 85 total votes Your vote: How many spaces do you indent? (Vote): 1 (Vote): 2 (Vote): 3 (Vote): 4 (Vote): 5 (Vote): 6 (Vote): 7 (Vote): 8
EDIT AND WARNING: I would hope most of you would know this, but do NOT use tabs unless you make sure that whatever editor you are using converts them into spaces first. Tabs are not good to use...
|
|
Canada10349 Posts
I use tabs Or 4.
|
4 spaces is the standard I think. I highly recommend it.
|
I use 4. I started this way and now I don't even consider it. I you dislike someone's style of indentation why not configure your IDE to convert them on pull and reconvert on commit?
|
I thought everyone used the tab key. I use the tab key. In what case would not be using the tab key be appropriate and/or better?
|
On August 31 2011 03:58 myzael wrote: I use 4. I started this way and now I don't even consider it. I you dislike someone's style of indentation why not configure your IDE to convert them on pull and reconvert on commit?
Because it doesn't bother me that much and I'm not using an IDE. I'm on linux using gedit .
|
I use 4, it's N++'s default and it works best with Python imo. I do use tabs actually, never really had any problems with that (Notepad++ automatically tab-indents with Python).
|
In most editors, I set tab to 4 spaces. In Notepad2 I use 2 spaces for web-oriented languages.
|
if( spaces == 4 ) { spaces = perfect; } else { programmer sucks }
|
why would anybody not use tabs? as long as you use the same indentation character throught your code, why not use tabs? I actually set my IDE up to only use tabs, because i really dislike having 16 different text cursor positions in front of my code instead of just 4, which actually are at exactly the spots where i could want to move indented code to. Using multiple spaces instead of single tabs requires a lot more micro management when selecting passages by mouse or keyboard properly, why would anybody prefer that?
|
On August 31 2011 04:28 MisterD wrote: why would anybody not use tabs? as long as you use the same indentation character throught your code, why not use tabs? I actually set my IDE up to only use tabs, because i really dislike having 16 different text cursor positions in front of my code instead of just 4, which actually are at exactly the spots where i could want to move indented code to. Using multiple spaces instead of single tabs requires a lot more micro management when selecting passages by mouse or keyboard properly, why would anybody prefer that?
People avoid using tabs because it doesn't look the same in every editor.
|
On August 31 2011 04:28 MisterD wrote: why would anybody not use tabs? as long as you use the same indentation character throught your code, why not use tabs? I actually set my IDE up to only use tabs, because i really dislike having 16 different text cursor positions in front of my code instead of just 4, which actually are at exactly the spots where i could want to move indented code to. Using multiple spaces instead of single tabs requires a lot more micro management when selecting passages by mouse or keyboard properly, why would anybody prefer that?
Because when viewed under different editors (you might not be the only one viewing the code) there may be different tab display settings in those editors, and you could end up with some horrendously misaligned stuff.
|
Depends on the screen of myself and whoever is reading the code.
On a 19", I use 2.
If I have a 24" wide-screen, I use 4.
|
Why did people ever use 8 back in the day anyways. Sounds horrible.
|
I use tabs, and whenever my me and my co-workers go into the same files and muck around the result is always the end of virtue and the triumph of malignant chaos. Cba to fix.
|
One would expect that people working together would make sure that problems with editor differences don't ever occur.
Seems a lot easier to do than pressing space space space space (at least!) every line. If I started doing that, it would kill me. -_-
|
why would anything misalign if you use tabs? if you need to draw ascii arts into your code, make spaces from where the default indentation ends at these lines, obviously don't use tabs inside "drawings". But for normal indentation tabs are perfectly fine.
and seriously, are there still people who are incapable of setting up their tab displaying today? i mean, you don't have to use the windows editor for programming anymore, anyone who does and actually feels like he really has any reason to complain about that .. well, i wouldn't want someone like that touching my code anyways xD
i would value usage comfort higher than compatibility with people who cannot set up their editors properly. Sure, spaces are more compatible, but they are just a lot more inconvenient. And working around the incompatibility should no be a problem for anybody, so that surely does not outweigh the increased comfort when using tabs?
/edit:
On August 31 2011 04:40 Talin wrote: One would expect that people working together would make sure that problems with editor differences don't ever occur.
Seems a lot easier to do than pressing space space space space (at least!) every line. If I started doing that, it would kill me. -_-
you actually don't type "space space space space", you type "tab" and your editor just writes down 4 spaces instead. But any editor that can do that is pretty much guaranteed to have tab display settings, so you might as well use tabs.
|
Tabs don't work well because different people prefer different IDEs/editors and operating systems, so it's almost impossible to use tabs. Also, most diff tools don't work well with tabs from different OS.
Just because you use 4 spaces, it does not mean you have to press 'space' 4 times. Most IDEs offer you the option to use "soft tabs" which converts tabs to spaces automatically.
|
On August 31 2011 04:41 MisterD wrote:why would anything misalign if you use tabs? if you need to draw ascii arts into your code, make spaces from where the default indentation ends at these lines, obviously don't use tabs inside "drawings". But for normal indentation tabs are perfectly fine. and seriously, are there still people who are incapable of setting up their tab displaying today? i mean, you don't have to use the windows editor for programming anymore, anyone who does and actually feels like he really has any reason to complain about that .. well, i wouldn't want someone like that touching my code anyways xD i would value usage comfort higher than compatibility with people who cannot set up their editors properly. Sure, spaces are more compatible, but they are just a lot more inconvenient. And working around the incompatibility should no be a problem for anybody, so that surely does not outweigh the increased comfort when using tabs? /edit: Show nested quote +On August 31 2011 04:40 Talin wrote: One would expect that people working together would make sure that problems with editor differences don't ever occur.
Seems a lot easier to do than pressing space space space space (at least!) every line. If I started doing that, it would kill me. -_- you actually don't type "space space space space", you type "tab" and your editor just writes down 4 spaces instead. But any editor that can do that is pretty much guaranteed to have tab display settings, so you might as well use tabs.
In a sidenote, if I ever want to edit an html file through the web editor in cpanel, it looks horrendous whenever I tabbed instead of soft tabbed. Quite an eyesore.
But I usually just ftp that shit and use Notepad2, so it doesn't really matter very much in this case.
|
|
|
|