Death to Carriage Returns and Linefeeds
130 years later and the typewriter is still slowing me down. When you type on a typewriter (for those of you under 25(?) who've never seen one) and reach the end of a line you grasp the "carriage return bar" which would return the carriage to the home position while simultaneously rotating the platen to feed the paper.
Aside: I spent the better part of the summer 1985 manually typing up the screenplay to Ghostbusters (as a reference material) on a manual Smith-Corona Typewriter.
Fast-forward to Teletype machines and now the carriage return/line feed combination is encoded into the wire protocol, then baked into ASCII text encoding itself in the 60s.
Fast-forward to lunchtime today when I was trying to commit some user-submitted changes to DasBlog via TortoiseSVN and got this fantastic error message "Commit failed: file has inconsistent newlines." What application would be so clever as to patch a file with consistent CR/LF pairs with a band-aid of just LFs? Why TortoiseMerge of course! But I'm not bitter.
How do you fix something like this? Well, a number of ways.
- Sometimes if you open the file in Visual Studio it will detect the inconsistencies and offer to fix them.
- You can use some of the dos2unix or unix2dos tools at the command line.
- You can use Notepad++ or Notepad2 (or Scite) - for this I prefer the cleaner Notepad2 status-bar implementation.
Here's screenshots of the same file opened in Notepad++ and Notepad2.
Notepad2 shows the the CR/LF status in the status bar and also optionally at the end of each line. It also lets you switch line endings by simply double clicking on the status bar indicator. Slick. Anyway, crisis averted and changes successfully committed.
Will we ever be rid of this problem?
No, just like Intel will always been little-endian while the rest of the world will be big-endian. As an unrelated aside from Alex McLellan:
The terms big-endian and little-endian were taken from the Big-Endians and Little-Endians of Gulliver’s Travels, when Lilliput and Blefuscu Gulliver finds two factions fighting over which end of a boiled egg should be cracked open.