Part 8 - Edit

This time I wanted to give a quick run down on !Edit. This is a great program, supplied with every version of RISC OS since version 2. If you've never used !Edit, you should probably have a go at your earliest opportunity.

More than a basic editor

Edit is more than just a basic featureless editor. One of the primary things which Edit supports, over and above editing text, is that it has a BBC BASIC compatibility mode so that if you load BASIC programs into Edit, you see the de-tokenised version which is editable. Additionally, as you would expect, you can save out the BASIC program back into its original format just as easily as saving any other file.

Another extremely useful feature of edit is the extensive search & replace functionality (which I still use in preference to Zap for some things).

I often find myself comparing !Edit to Notepad under Microsoft Windows, but !Edit is far far more superior to Notepad in many ways. In some versions of Notepad (Win95 / 98?) there is apparently no search / replace, only a search. Also !Edit supports word-wrap and can be used to compose simple documents which don't spill over reasonable margins (unlike notepad).

Search & Replace

As mentioned earlier, I use Edit extensively for search and replace operations on text files and data files. The main reason for my use is that I learned a lot of the keyboard shortcuts early and have found the "magic characters" feature invaluable with some very complex replaces. !Edit has been employed on many occasions at my place of work for re-formatting debug trace files from some of our systems into more easily manipulatable text.

The power of !Edit's search and replace comes from the fact that you can easily search for newline characters and certain other categories of character using codes as depicted in the screenshot. This screenshot shows an example search which looks for a newline character, followed by the word "edit"; because the "Case Sensitive" box is ticked, it will only match on a lower case "e". This search would then replace (if you confirm) any lower case "edit" with "!Edit" providing that it was the first word of a line.

Converting DOS text

If you have ever used a text file produced on a PC, chances are you've experienced the CR/LF problem. DOS text files use both at the end of a line, RISC OS tends only to use LF. When you load a DOS text file into edit, you see the normal text, line feeds produce the intended effect and carriage returns produce a control character as pictured ([0d] - which is 13 in hex and the ASCII code for a carriage return).

Edit has a feature "CR<-->LF", which can switch line feeds for carriage returns and vice-versa. Combining this with search and replace of new lines with nothing, you can strip out line feeds and then switch all the carriage returns to be come line feeds, thus stripping out the unwanted characters for RISC OS.

The reverse of this scenario is as you might expect, if you produce a text file on RISC OS (and some Unix machines I've used too), loading them into Notepad for Windows results in one huge line of text because there are no carriage returns and Windows expects there to be. Thankfully due to some legacy software still being around (DOS Edit), you can sort this very quickly. DOS Edit (type edit at a DOS Prompt) reads text files with just Line Feeds and adds Carriage Returns for us so loading your RISC OS text file into DOS Edit and Saving again solves this issue.

Task Windows

Edit is also the host program for task windows, so if you ever have the need to grab the textual output from a command line program, all you need do is to run it in a task window, navigate to the Edit Menu over the window and save as if it were a normal text editing window.

That's all for this month as I'm struggling for time, as I write this (early December) I'm being distracted by thoughts of another business trip to London.


Index - Back - Forward