Editing plain old text files

Allan Crowson

I am attempting a trial migration of our OS9/WebSTAR/Lasso intranet site to OSX/Apache/Lasso(OSX beta!), and need to be able to edit text files. Lasso requires the files to have a .lasso suffix, rather than HTML, and I need to be able to edit the files. Under OS9, any number of editors (SimpleText, BBEdit, Tex-Edit) could open text files regardless of any suffixes. Now, under OSX, I can't open a simple HTML text file with a .lasso suffix! Yes, I tried the OSX beta for Tex-Edit. I've yet to open a previously existing document and not crash. So much for that. The bundled TextEdit insists on trying to render the HTML, and I can find no way to get to the underlying source. The bundled HTML Editor won't open half the .html files I have, even in source mode, and absolutely refuses to recognize any .lasso files. Does anyone know of a way to work in plain old HTML source mode on HTML files, especially files with something other than a .html suffix? Without going into Classic?!?!?
My glib 'use vi' remark made me think of a can o' worms waiting to pounce
on unwary MacOS X users: Classic uses ^M as the end of line while BSD use
^J. I..e, there are two flavors of text files on your system and half the tools
aren't ready to deal with the text files created by the other half.

Is there a tool on MacOS X to convert the end-of-line characters one way
or the other? I don't even have Classic installed, so everything I'm doing
uses the Unix flavor text format (unless I download something from on
of my other Macs over the net). I've got a little command-line app I
wrote similar to

#include <stdio.h>
void main( void )
int x;
while ( ( x = getchar() ) != EOF )
switch( x ) {
case '\r': x = '\n'; break;
case '\n': x = '\r'; break;
putchar( x );

to deal with the situation (note: I typed the above code in off-the-cuff and
haven't compiled it; it seems OK, but it may not work).

This problem is yet another indication of the half-baked nature of MacOS X.
Originally posted by endian
Have youset TextEdit's prefs to ignore rich text commands in HTML files?

That appears to have done it. I'd tried that earlier, but apparently it didn't work right unless I applied the pref, and then opened the files. It dind't seem to work on open files, so I assumed it wasn't working. Thanks!
yeah you have to reopen the file.

I agree it is harder than it has to be, but hopefully BBedit will fix that before final with a carbon version (even though it works fine in classic now).
If you're going to attack it with Terminal.app, why not use emacs? It's at least somewhat closer to intuitive than vi.... The simple way of solving your CR-LF/newline problems is to use a perl commandline (or awk, I suppose, but I don't know awk).

To make mac files legible in Terminal I use

<code>perl -pe 's/\r/\n/g' myfilename > mynewfilename</code>

which does the job nicely. Though I think emacs is savvy to the CR-LF problem in any case.