The chapter begins with a reminder that files can be collections of binary code. Well, they all are, really. Some are meant to readable and editable by common mortals, not just by programmers with integrated development environment tools. Sometimes, binary code stands for machine language, such as the contents of executable files. Sometimes the files are just plain text, and this chapter wants to show us some tools for creating and editing text files. In a computer system, we typically have to represent all numerals and characters as items in a numbered list. Once such a list is created, each numeral and character can be represented simply by its number, which is then converted to a symbol that can be printed on paper or sent to a screen for a user to read.
I think the author has gone a little bonkers on page 112. He probably should have said that some text files are written in ASCII, and some are not. ASCII stands for American Standard Code for Information Interchange. Files written in ASCII (pronounced like ask-key) may be written in just the original 128 characters defined by seven bits of a byte, or in the extended ASCII code that uses eight bits. See the table of defined characters on this web page. ASCII was not created by our friends at IEEE. It was created by ANSI, the American National Standards Institute.
The text mentions another character coding system, Unicode, which uses two or four bytes for each character. Another system is the one that was used for years on mainframes. It was called EBCDIC.
So, an ASCII file is intelligible to an editor that understands Unicode, which means that more systems will be able to read it. UNIX has been around since ASCII was developed, so it features several available file editors that can read and write such files. The chapter introduces us to two text/ASCII editors: vi and Emacs. Both are what the text refers to as screen editors. To understand this point, you need to know that editors can be sorted into two categories:
The main reason for mentioning this is to console us that vi and
Emacs are screen editors, and more user friendly than their ancestors.
Other editors exist, and you may want to consider any of them as alternatives.
See this short review
of several editors that can be added to most UNIX/Linux systems.
is called vi because it is meant to be more visually
oriented than older editors. As the text explains, it immediately displays
changes that you make. (Rather what we would hope for, isn't it? Other
editors did not display their changes to their users. You may wish to
gasp in terror.) The book then tells us that vi has three modes,
each of which is used for a different purpose. These modes are called
by other names in other
documentation, which can lead to a lack of understanding when looking
for supplemental training material.
The text presents instructions on a series of topics about using vi (and vim, the version of vi available in Fedora, RHEL, and SUSE Linux).
The text finally gives us a reason to know about ex mode on page 119 with the explanation of the Search and Replace command. As noted above, press Esc to enter command mode, then : to enter ex mode. The text explains that the command we have seen up to this point are screen oriented commands, which take place at the cursor position. An ex mode command is a line oriented command, which will find all lines in the file that meet the command's requirements and make the specified changes. This is not very intuitive terminology, but that is nothing new in UNIX/Linux.
To execute a search and replace, first go to command mode. Then enter something like this:
In the example in the text, the command is :1,$s/insure/ensure/g
1 means line 1. $ means the end of the file. s means to search, insure and ensure are the search and replace strings, and g means to do it on every line that matches the search string.
Take a deep breath, let it out slowly, and think of something that would make you happy. Do this for a minute. I will wait here. If you have taken a break and need some convincing that rational people in the 21st century would actually choose to use this program, consider this article by a possible convert who learned a few reasons to appreciate vi.
Page 120 continues the lesson with advice about saving your work and exiting vi.
Copying from one file into another is one version of doing a copy and paste operation. In vi, it is not as simple as you are used to. In vi, you open the file (call it the destination file) that is to receive text from another file (call it the source file). Enter command mode, and use the command :r filename. In this command, the filename is the name of your source file.
On page 122, the text describes cutting, copying, and pasting in the same file.
The text changes topics on page 123, beginning its discussion of Emacs. We are told that unlike vi, Emacs has no modes, and that commands are often issued in it with Alt or Ctrl key combinations. The tutorial for Emacs that is included with it discusses using these key combinations to navigate the screen, and to edit a document. A chart of these keyboard commands appears on pages 124 and 125. This list of commands, while valid, is misleading. Read ahead a bit and you will find that Emacs has a GUI interface that "runs under X Windows", which means that it will partially understand a mouse under whatever GUI your system might be running. Emacs is like a cross between a character based word processor and a GUI based one.
The text only discusses Emacs for a few pages. It make more sense to
me to mention that this distribution of Fedora comes with LibreOffice
installed. LibreOffice is a free office suite that works a lot like Microsoft
office. It is much more familiar to users and you will be much more productive
using it. You will not have permission to install this suite on every
Linux machine you may ever use, so don't depend on it having it, even
though it is free to download, install, and use. Learn vi and use it when
necessary. Learn LibreOffice and use it when you can.