Take the 2-minute tour ×

Similar Questions

While coding, how many columns do you format for?
What is a sensible maximum number of characters per line of code?
Do people still live by the 80 column rule?
The 80 column limit, still useful?

By code margins I am referring to the lines that guide how long a particular line of code is. Different IDEs have different language for this device, I believe Visual Studio calls them 'gutters'.

That being said, is there a particular standard to the length code margins? My IDE (Netbeans) has 80 by default but I was wondering if there was any rhyme or reason to that default.

share|improve this question
Many duplicates: stackoverflow.com/search?q=80+columns –  Josh Lee Nov 3 '09 at 15:25
@jleedev, Thanks for pointing that out, I missed those. –  James McMahon Nov 3 '09 at 15:28
add comment

6 Answers

up vote 10 down vote accepted

We've been using 80 columns for over 80 years, thanks to IBM's punch cards. It's the default text mode on a PC, and it's the default size of a terminal window. Keeping your lines under the 80 column limit means they can be displayed without wrapping in those environments.

I believe the Visual Studio default is 120 columns (although that can be changed), which in my opinion makes more sense given the LongVerboseDotNetCompliant naming conventions. When working in an IDE, it's pretty common to maximize it, so an 80-column limit tends to waste space unless you have a lot of sidebars open.

I happen to prefer 72 (when writing HTML, Python, etc.), which allows my code to fit in a standard terminal with room to turn on line numbers.

share|improve this answer
you just barely beat me to it...this is the REAL answer –  Chris Shouts Nov 3 '09 at 15:25
Nice to know where this standard originated. –  James McMahon Nov 3 '09 at 15:42
It's not just from punched cards. Typewriters could type 80 10-pitch fixed-width characters across an 8-inch wide piece of paper. –  David R Tribble Nov 3 '09 at 16:35
add comment

This is normally set to 80 because this is the standard width of a terminal in characters, allowing code to be easily viewed from the command line.

It's still popular in languages like python where whitespace is important and it's common to work with the interpreter via a CLI, but is becoming less standard in other languages.

share|improve this answer
add comment

Depends on:
1) whether you're going to print the code onto paper (e.g, for handouts at code reviews);
2) what environment anyone else who examines or maintains the code will use.

80 columns is the universal standard (as stated prevously), so code that fits within that width can be printed on any printer in existence. Likewise, 80-column code can be viewed and edited by any editor in existence without having to deal with line wrapping.

On the other hand, if you know your team is always going to be using widescreen IDE editors and landscape-mode printing, 120 columns is a reasonable code width maximum.

You should also use a reasonable indentation width, such as 3 to 5 spaces. 2 spaces is usually too small to see aligned statements in long methods (but okay for small methods in languages like SQL), while 8 spaces uses up quite a lot of horizontal real estate unnecessarily.

share|improve this answer
add comment

I typically code at a size that some unlucky individual could be able to view it on 1024x768

share|improve this answer
add comment

80 columns has an additional advantage, other than compatibility with less capable environments: long statements that are broken up into shorter lines in a semi-intelligent manner are generally easy to read than a single 120-column line, even if the environment can display that without wrapping it.

share|improve this answer
add comment

I have seen people using long (120 or more) columns, but I stick to 80 columns for reasons explained above and others such as:

  • Ease of code review - either via printing or using tool (Code Collaborator)
  • Split screen on 17" or above monitors. Two code windows side by side (e.g. header and cpp) allows easier coding.
  • Avoids going to too many nested code, it helps keep logic simple!
  • Helps writes more concise and simpler code, due to short and simpler names, easier logic etc.

So, it all depends on whether you are working alone and how all the code will be consumed - read or maintained by others etc.

share|improve this answer
add comment

Your Answer


