Most Text Editors Get Tabs Wrong
Why do PC based text editors get tabs wrong?
I’ve been getting back into COBOL and writing a book on GnuCOBOL. This lead me to writing a book on Emacs. For no more people than they have, they’ve done an amazing job. This lead me to poking around for the correct editor, preferably one that could be close to a full blown IDE.
I know. During my VAX/VMS days I happily used EDT, dropped to the command line to compile, then ran the executable under the VMS Debugger. All in a hardwired terminal. When we got LSE where I could compile and fix errors in the editor it was fantastic.
When I’m on a PC, I want something close to an IDE. It’s a psychological thing and no, I don’t feel like going through therapy. I have the same psychological thing about driving. When I’m in the city of Chicago I will walk for miles once I have a place to park my car. When I’m in the suburbs I’ll drive if it is more than a block. This can happen on the same day.
Visual SlickEdit Pro
This lead me to try many different editors. I tried Visual SlickEdit Pro. At $299 or whatever dollars for a single OS installation, man does it suck. I spent half an hour trying to get it to compile and debug GnuCOBOL and couldn’t make it work. The only reason I was interested in the Pro version was it claimed debugger support. I uninstalled the free trial within two hours of getting it.
Quick COBOL failures
Sublime Text kind of let me down as well. I still own it, but it was kind of rough when it came to COBOL. Actually the real downfall was the Debugger package required creation of a “project.” I wasn’t ready to bite the bullet of yet another “project file” syntax. Notepadqq had great color syntax if and only if you were using the original 80-colum fixed format. KDevelop has had people begging for a COBOL plug-in for years but no takers. The Eclipse COBOL plug-in is apparently abandoned.
Someone pointed me to VSCodium. This had some issues, but it looks nice when you are writing fixed format COBOL.
Not so much when using free format COBOL.
The one thing it got right is the TAB key. Your first TAB puts you into Area-A (column 8, just over the second gray vertical line). Your second TAB puts you into Area-B (column 12). The first two gray vertical lines mark the comment/continuation column. I guess technically the first one marks the end of the line number column range.
All of this lead me to try justifying once again paying $99/year for UltraEdit. I have a love/hate relationship with UE. There are things I really like. There are far too many things half-assed. That is one of the many reasons I don’t currently pay $99/year to them.
If I’m paying for an editor I shouldn’t have to hack a hidden script somewhere to change the C++ coding style. When the Linux version is treated like an ugly red headed step child chained in the basement, I don’t feel compelled to fork over the cash either. Professionals don’t use Microsoft products.
Oh yeah, debugger support. That only works in UltraEdit Studio. Oh yeah, UltraEdit Studio only runs on Windows.
Tabs are inexcusable
The syntax highlighting wasn’t bad. What was inexcusable was the tab. Sublime Text, UltraEdit, notepadqq, and KATE all get this wrong. The vast majority of PC text editors get it wrong. Emacs gets it right. Emacs also supports GDB on Linux. I can put the following two lines in my .emacs file and tabs work exactly as they should.
(setq-default intent-tabs-mode nil) (setq default-tab-width 4)
Sitting in an empty file in Emacs with those in my init file, my cursor is at column 1. Hit the tab key and my cursor is in column 4. Exactly as it should be. COBOL programmers adapted to this years ago when we were forced to use non-COBOL specific coding tools. Today’s kids never used a manual typewriter. They have no idea how tabs are supposed to work, so they guess.
I hate linking to images. The sites go down and you get an empty spot. If terminals-wiki.org ever comes back up you should see the images.
I no longer have either my VT-100 or VT-220 so cannot take a shot myself. Given that we will first go here.
Well, I found one of the shots, just not the one I was looking for.
Now we have to think why COBOL’s Area-A starts in column 8.
Hopefully your browser will let you zoom that image to full screen. Yes, that is a picture of COBOL coding sheets I’ve saved since junior college. We bought these tablets by the pack. We had to hand write every line of COBOL, get it proofed, then we were allowed to type it in.
Typewriters set the standard for tabs
On both manual and electric typewriters, well, IBM and Smith Corona which were the two biggest brands of the “modern” typewriters once we got rid of the Underwood that didn’t even have all of the keys, the first physical tab stop put the next printable character at column 8. Wow! Someone had a good one of these!
The carriage/platen stop was always placed one character travel beyond the type guide. There was a gear with a toothed rail controlling all of this. Keypunch machines and paper terminals maintained this convention in large part because the early models of both were little more than customized typewriters.
VT terminals saved the day
COBOL programmers fortunate enough to have a VT-52, 100, or later were overjoyed. Not only did it allow you to manually set the tab stops, it came with two setups, A and B. A, the default power-on setup, was almost always left to factory tabs of 8. This was so if mere mortals needed to use it they could. Setup B was normally used by COBOL programmers. The first tab stop of 8 was left in place but an extra tab stop was placed at 12. If you worked at a shop that had a “final comment” standard, you added a tab stop which put your cursor in column 73.
PC based editors suck at tabs
What happens with UltraEdit and most ill designed PC editors is they simply insert 4 spaces. Sitting in column 1, you hit tab and you land in column 5 when you have tab-width set to 4. The second tab lands you in column 9. You can do the math from there.
The ultimate test is rather simple. Pull down GnuCOBOL. Use UltraEdit or your favorite text editor with soft tabs set to 4. Type in a simple “Hello World” COBOL program using the tabs you say are correct and the 80-column “fixed” card format pasted above. Compile the program. It should fail miserably because Area-A starts in the wrong place. When text editors implement tab stops correctly, this doesn’t happen.
cobc -x -fixed -std=cobol85 COB001.COB
There was a method to the madness. Today’s kids just didn’t bother to learn it. Thank God for Emacs!