My editor has a default of 80 characters, and I'm wondering if this is too small (or too large).
- How many characters wide should the code be?
- How wide is yours?
- Did you ever even notice that your editor has this setting?
|
My editor has a default of 80 characters, and I'm wondering if this is too small (or too large).
|
|||||||||||||
|
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.
|
Most people use either 80 or 72/73 character width. Some use up to a 100, but that already sometimes presents a problem with printing. Besides, long lines are (at least to me) hard to look at. I prefer vertical layout of code, not "infinite" rows ... Mine is 72. Btw, if you search SO on this topic you'll find somewhere a link describing the results of a research some time ago that showed that most publishers for example, also use a (my memory is somewhat vague on this, but maybe) 66 char. width per page. It was shown to be easiest to read. |
|||||||||||||||||
|
|
I use an IDE that isn't terminal centric. I try to maximize the screen real estate of the editor window (on a 1600x1200 screen) and simply avoid horizontal scrolling. I also don't try to fill up each line, but will use returns at logical points to make the code more readable even when the code might fit on a single line. For example, when using a fluent style with LINQ:
Readability, not screen width, ought to be your biggest concern. Having said that, limiting your line length to the minimum of the people on your team and making sure that people on your team have a reasonable minimum line length is a really good idea. The last thing you want is people reformatting code (and checking it in) just so they can read it easily. |
|||||||||||||
|
|
I've seen in "Best Practices" lists and books that < 80 is correct. My editors and screens support a lot more than that, and I find 80 columns very restricting so I'll go past that. I do try to stay with 132 though, as I find lines beyond that to be unwieldy. |
|||
|
|
|
There is no, one, right answer to this issue. I use 120 characters in my IDE, but 80 is an old standby. If your code is consistently longer than your display width it could mean the width is too narrow, or your code needs some attention. Keeping line lengths sane is important for code readability. Some will object to anything above 80 because of issues with printing code, but I respond to those concerns by asking why anyone is printing code on paper that isn't going into a book on programming. Regardless of the width you choose, it is more important to make sure your code makes sense and that you aren't cramming more than what's necessary into a single line. If you have lots of long lines of code you may be "doing it wrong." If you can justify a line of code that is 80 characters wide or 120 characters wide then go for it. |
|||
|
|
|
For me variable width fonts are much easer to read than fixed width fonts. With my current settings there's room for about 240 characters in the width of my editor. It varies a bit depending on how wide I want other windows to be. |
|||||||
|
|
80 characters. I programmed a custom key command for Emacs that would resize the window to 160 characters so I could split the screen without having to take my hands off the keyboard. Then I put it somewhere on one of my monitors and I have a couple terminals on another window. Along with Firefox for google/stuff to read during a long compile. I then also have a music player up on the same screen. The more things I can see without having to use Alt+Tab or a mouse the better. |
|||
|
|
|
Discarding the margins both left and right, the central column of this very page, programmers.stackexchange.com appears to be 80 characters wide. I guess the reason behind that could be easy on eyes or something similar. Or, it could be because text based programs normally use 80 character width. |
|||||||||||
|
|
This dates back to the quaint old days of paper printout. Seriously, it's easier to just get some more screens. (They only come in wide these days.) <I'm not really this fogey> You try getting green bar paper for your 132 column printer. It ain't as cheap as the 80 column greenbar. (And you can't get 200 column greenbar, so you can't print that code.) </I'm not really this fogey> Old fogies (like me) refer to greenbar, which is paper with preprinted green bars on alternate 3-lines. Classy greenbar even discreetly numbered the lines. The paper has tractor feed holes on the edges, for the printer, and is in continuous sheets, with perforations every page. The bars aren't necessarily green, they can also be yellow, and I've seen an orange-ey yellow. The edges of the bar are 100% saturation, and the fill is about 25%. |
|||
|