Skip to main content

Questions tagged [indentation]

Filter by
Sorted by
Tagged with
4 votes
3 answers
5k views

Why do we still have programming languages that rely on indentation / white space? [duplicate]

A long time ago when starting learning programming I remember a teacher saying that compiler do not care about whitespace and they are useful to make code readable for human beings. It made perfect ...
Alexei's user avatar
  • 452
3 votes
1 answer
4k views

Why tabs are evil in ES6? [closed]

As I have recently started using ES6 in production, I was going through an ES6 style guide (having more than 350 stars on GitHub). This guide mentions at least three times that "Tabs are evil. Don't ...
mg007's user avatar
  • 155
0 votes
3 answers
5k views

"with open() as" and indentation

I could not find any official recommended indentation for the following idiom (straight from http://effbot.org/zone/python-with-statement.htm): with open(path) as f: data = f.read() do ...
Aristide's user avatar
  • 157
4 votes
5 answers
775 views

C++ auto-indentation (auto-style) in a multi IDE team

Is there a convenient and sustainable way to handle code indentation and style in a team in which multiple IDE's (Emacs, XCode, VS) are used by different programmers? We are using git, so, should we ...
Halil  Sen's user avatar
  • 149
2 votes
1 answer
562 views

Why does nobody use indentation in css? [closed]

I find css quite hard to read sometimes. Indents, depending on the dom structure, would greatly increase readability. Consider the following example: #page { text-align:center; font-weight:...
phil294's user avatar
  • 179
8 votes
3 answers
219 views

Indentation in a multi-language file [closed]

In files that contain multiple languages (ie. template files), are there any best practises regarding indentation? I mostly use this: <div> IF FOO <div> <p>...
Celos's user avatar
  • 267
22 votes
8 answers
5k views

At what point is it taboo to have loops within loops?

Just curious. The most I have ever had was a for loop within a for loop, because after reading this from Linus Torvalds: Tabs are 8 characters, and thus indentations are also 8 characters. There ...
Anon's user avatar
  • 3,613
2 votes
1 answer
294 views

What is the name/origin for this C code indentation style?

Look at the formatting of the variable declarations. I haven't encountered this indentation style in the past, but lately I stumbled upon two different code examples which use this style. Where does ...
Paul's user avatar
  • 161
30 votes
3 answers
1k views

Origins of code indentation

I am interested in finding out who introduced code indentation, as well as when and where it was introduced. It seems so critical to code comprehension, but it was not universal. Most Fortran and ...
Daniel Mahler's user avatar
16 votes
5 answers
8k views

Keep indentation level low [duplicate]

I hear a lot that you should not write functions larger than one screen size, that you should extract things into functions if you call things very often and all these coding guidelines. One of them ...
reox's user avatar
  • 293
9 votes
4 answers
2k views

How strict should you be about indentation/white space? [closed]

Our development process is as follows code the task -> someone else QAs code and documentation -> task is merged into trunk. Recently a colleague is refusing to pass the code QA due to issues with ...
dwjohnston's user avatar
  • 2,677
15 votes
7 answers
7k views

Should I write compact code or code with lots of spaces? [duplicate]

I have two friends that have completely different schools of thought on how to lay out their code. The first says that code should be well-indented and use lots of spaces and to name variables ...
Peter Olson's user avatar
  • 1,062
21 votes
5 answers
10k views

What are the downsides of mixing tabs and spaces? [duplicate]

The advantage of using tabs for indentation is that people can configure their editor to use the tab width they are comfortable with. The only argument against this seems to be that people don't want ...
Overv's user avatar
  • 1,170
1 vote
1 answer
1k views

Heredoc or an external template file in my bash script - how it affects readibility/maintanance?

I realise that this question may be down to personal preference but I'm pretty new to Bash / shell scripting so thought it'd be worth some research to see if there's some sort of standard/best ...
Bucky's user avatar
  • 185
25 votes
6 answers
5k views

Reformatting and version control

Code formatting matters. Even indentation matters. And consistency is more important than minor improvements. But projects usually don't have a clear, complete, verifiable and enforced style guide ...
l0b0's user avatar
  • 11.5k
4 votes
4 answers
3k views

Indenting labels in C

I noticed that in the Vim automatically indents labels in a rather unintuitive way (IMHO). int main(void) { goto end; end: return 0 } Are there any style guidelines for labels? For the ...
tskuzzy's user avatar
  • 752
3 votes
3 answers
463 views

Eliminating tab characters in a new language

I'm working on a new programming language, which determines structure with indentation instead of braces in the manner of Python and CoffeeScript. Obviously placing lines indented with spaces next to ...
rwallace's user avatar
  • 1,198
87 votes
12 answers
12k views

What are the drawbacks of elastic tabstops? [closed]

Look here: a typical holy war on tabs vs spaces. Now look here: elastic tabstops. All problems solved, and a bunch of very useful new behaviours added. Are elastic tabstops even mentioned in that ...
Roman Starkov's user avatar
15 votes
5 answers
5k views

Why do some languages recommend using spaces rather than tabs? [closed]

Maybe I'm alone in this, but few things annoy me like people indenting using spaces rather than tabs. How is typing SpaceSpaceSpaceSpace easier and more intuitive than typing Tab? Sure, tab width is ...
Naftuli Kay's user avatar
  • 1,631
4 votes
3 answers
3k views

Why do XSLT editors insert tab or space characters into XSLT to format it? [closed]

All XSLT editors I've tried till now add tab or space characters to the XSLT to indent it for formatting. This is done even in places within the XSLT where these characters are significant to the XSLT ...
pgfearo's user avatar
  • 944
60 votes
3 answers
79k views

What is the difference between K&R and One True Brace Style (1TBS) styles?

I have read the Wikipedia article on Indent Styles, but I still don't understand. What is the difference between K&R and 1TBS?
GavinR's user avatar
  • 703
239 votes
14 answers
31k views

How can a code editor effectively hint at code nesting level - without using indentation? [closed]

I've written an XML text editor that provides 2 view options for the same XML text, one indented (virtually), the other left-justified. The motivation for the left-justified view is to help users 'see'...
14 votes
8 answers
772 views

Styling compound AND / OR if statements

How do you style complex compound AND / OR if statements for maximum readability? How do you indent and where do you place the line breaks? My particular situation is something like the following. It'...
JoJo's user avatar
  • 1,495
1 vote
2 answers
236 views

"Functional" php indentation

I'm a big fan of 1tbs when it comes to c-like languages. Now that php got decent lambdas and closures, though, I'm not sure the style I'm using for them (fundamentally made up, has something to do ...
cbrandolino's user avatar
  • 1,999
6 votes
4 answers
537 views

Correct alignment when outcommenting code

Suppose I have some code void some_block(void) { some_statement_1(); some_statement_2(); some_statement_3(); } Now I wish to out-comment statement #2, but here I never can find a way ...
Bjarke Freund-Hansen's user avatar
18 votes
9 answers
9k views

How to prevent deep indentations? [closed]

What steps and measures can I take to prevent deep indentations in my code?
Tamara Wijsman's user avatar
84 votes
22 answers
722k views

Tabs versus spaces—what is the proper indentation character for everything, in every situation, ever? [closed]

The coding standards for the code hosted in drupal.org suggest to use two spaces to indent the code; other sites suggest to use tabs to indent the code. What is the proper indentation character for ...