问题
Possible Duplicate:
Why use monospace fonts in your IDE?
Virtually all coders (and code editors) use fixed width fonts. Why is this?
回答1:
ask those guys.
回答2:
Probably because it makes the code easier to scan - you have "blocks" of code, ie. text that lines up vertically far more often than you would in normal prose. If the font is not fixed width than it wouldn't be visually aligned.
回答3:
It greatly enhances readability - expecially of punctuation characters which have a very important role in code and which variable width fonts often "squeeze" into minimal space.
回答4:
Just try a non fixed-width font.
回答5:
Because it helps with code layout and make it easier to spot errors as lines are a consistent length for a given number of characters.
It is also historical as we used to use terminals with fixed width fonts.
回答6:
I know I am a week late to the game but I can't believe that there is no mention of programming languages like FORTRAN that basically required fixed width fonts. Comment chars had to go in column 1, line continuation chars in column 6 and that is not even mentioning the inherent fixed width font effect of punch cards. Mention has been made of fixed width fonts on terminals, but programming predates even that.
回答7:
I would add a few minor reasons, mainly related to the code's visual flow:
- You can align variable assignments (or not)
One typical example would be aligning table declarations so that it will look like a table in the code.
var sn = [ 8349824, 3094230, 1]; // first table line var longname1 = [ 421, 1324, 5382920]; // second table line // Try and do something as readable in variable width font!
You can agree on a line-width limit that will have a consistent effect.
- Your code has the same "face" everywhere - whether you read it in a
<code>
block on the web, in your basic text editor on a remote terminal or in your graphical IDE with antialiased fonts - you will immediately recognize the code. - More predictable behaviour when navigating code - when I go up or down, I already know exactly where the cursor will end up.
In short, fixed-width font allows for finer grained control over source code appearance and readability, independant from the availability of any given font.
回答8:
typos/missing letters can be seen clearer
回答9:
It's a matter of choice. I personally prefer to use the very elegant Comic Sans or Purisa font for programming.
回答10:
open some code in your favourite editor... I'm presuming by default that your text editor will have a fixed-width font set.
Now change the font to Comic-Sans..... enough said!
Seriously though, fixed-width is much much clearer to read.
回答11:
Mostly for outlining. However it's also a habit. I come from the old school IDE's while they were still in MS-DOS.
Also companies like Microsoft have made fonts to make it "easier" to code with. I prefer the Consolas font myself while coding in Visual Studio.
Grz, Kris.
来源:https://stackoverflow.com/questions/3099753/why-do-we-use-fixed-width-fonts-in-our-ides