Programs that allow you to view PDF and PS files are referred to
as text viewers. They do not allow a user to edit the text
directly, but do allow the user to view the pre-formatted text.
9.1. Working with Text Editors
Red Hat Enterprise Linux comes with several applications that can be used to
write and edit program code. These programs are text
editors, programs that provide the user with
helpful highlighting and formatting options without making
changes or additions to the text. The most common of these text
editors are vi and
Emacs. Two additional useful editors
are gedit and
kate.
9.1.1. vi
vi is a shell prompt text editor.
This means that like less, opening
an instance of vi does not open a
GUI window. Instead, the contents of the file being edited
appear in the current terminal window. Because
vi works without a GUI, it can be
used to edit text files even when X
is not working.
vi operates via keystrokes —
listed below is a small set of the keystrokes necessary to
work with text in vi.
Key | Action |
---|
[i] | With a file open, press [i] to
enter Insert mode. This mode allows you to move the
cursor and to delete and add text anywhere in the
file. |
[Esc] | Pressing the [Esc] key at any time
takes you out of Insert mode and into Normal
mode. |
[w] | [w] writes your changes to the
file. Enter Normal mode, press
[Shift]-[:],
[w], and finally press
[Enter].
|
[q] | [q] quits
vi. Enter Normal mode,
press
[Shift]-[:],
[q], and finally press
[Enter]. To save your changes before
exiting, enter :wq. To quit
without saving your changes, enter
:q!.
|
[!] | [!] forces
vi to execute the commands
that precede it.
|
Table 9-1. Useful keys in vi
vi uses many more keystrokes. To learn more about vi, view the
manual page by entering man vi at a
shell prompt. You can also access the vim
tutorial but entering
vimtutor command at a shell prompt.
9.1.2. Emacs
Emacs is a text editor that
includes a GUI component. Like vi,
Emacs also makes use of keyboard
shortcuts to manipulate text. Users can choose between
working with the mouse or the keyboard; all commands are
available via either method.
Emacs can be customized extensively. Programs that customize syntax highlighting or add other functionality can be written and installed. Emacs even contains several games available from the
=>
menu, and a "psychiatrist" availabel from the
menu.
An Emacs tutorial is available by selecting =>
from the main toolbar.
9.1.3. gedit
gedit is the
GNOME text editor. It has
highlight modes for HTML, Perl, C, PHP, and many other
languages. gedit features print
preview, the ability to undo your changes, and tabbed editing.
gedit is fully integrated with
Nautilus.
9.1.4. kate
kate is the
KDE text editor. It also has
highlight modes for multiple programming languages.
kate uses split screens to display
multiple files. kate also has the
ability to open a terminal window within the application.
kate is fully integrated wtih
Konqueror.