| < Day Day Up > |
Traditionally, most Linux distributions, including Red Hat, install the cursor-based editors Vim and Emacs.
Vim
is an enhanced version of the Vi text editor used on the Unix system. These editors use simple, cursor-based operations to give you a full-screen format. You can start these editors from the shell command line without any kind of X Window System support. In this mode, their cursor-based operations do not have the ease of use normally found in window-based editors. There are no
| Note |
Red Hat Linux includes three fully functional word processors, OpenWriter, KWord and AbiWord. You can find out more on AbiWord at www.abiword.com . |
The gedit editor is a basic text editor for the GNOME desktop. It provides full mouse support, implementing standard GUI operations, such as cut and paste to move text, and click and drag to select text. It supports standard text editing operations such as Find and Replace. You can use gedit to create and modify your text files, including configuration files. gedit also provides more advanced features such as print preview and configurable levels of undo/redo operations, and it can read data from pipes. It features a plug-in menu that provides added functionality, and it includes plug-ins for spell-checking, encryption, e-mail, and text-based Web page display.
|
The K Desktop |
Description |
|---|---|
|
KEdit |
Text editor |
|
Kate |
Text and program editor |
|
KJots |
Notebook editor |
|
KWord |
Desktop publisher, part of KOffice |
|
GNOME |
|
|
gedit |
Text editor |
|
AbiWord |
Word processor |
|
Nedit |
GUI-based text editor |
|
X Window System |
|
|
GNU Emacs |
Emacs editor with X Window System support |
|
XEmacs |
X Window System version of Emacs editor |
|
gvim |
Vim version with X Window System support |
|
OpenWriter |
OpenOffice word processor that can edit text files |
All the K Desktop editors provide full mouse support, implementing standard GUI operations, such as cut and paste to move text, and click and drag to select text. Kate is an advanced editor, with such features as spell-checking, font selection, and highlighting. Most commands can be selected using menus. A toolbar of icons for common operations is displayed across the top of the Kate window. A sidebar displays panels for a file selector and a file list. With the file selector, you can navigate through the file system selecting files to work on. Kate also supports multiple views of a document, letting you display segments in their own windows, vertically or horizontally. You can also
Kate is designed to be a program editor for editing software programming/development-
KEdit is an older simple text editor
The editor KJots is designed to enable you to jot down notes in a notebook. It organizes notes you write into
Emacs can best be described as a working environment featuring an editor, a mailer, a newsreader, and a Lisp interpreter. The editor is tailored for program development, enabling you to format source code according to the programming language you use. Many versions of Emacs are currently available for use on Unix and Linux systems. The versions usually included with Linux distributions are either GNU Emacs or XEmacs. The current version for GNU Emacs is 20. x; it is X Window System–capable, enabling GUI features such as menus, scroll bars, and mouse-based editing operations. (See Chapter 13 for a discussion of the GNU Emacs mailer and its newsreader.) Check the update FTP sites for your distribution for new versions as they come out, and also check the GNU Web site at www.gnu.org and the Emacs Web site at www.emacs.org . You can find out more information about XEmacs at its Web site, www.xemacs.org .
Emacs derives much of its power and flexibility from its capability to manipulate buffers. Emacs can be described as a buffer-oriented editor. Whenever you edit a file in any editor, the file is copied into a work buffer, and editing operations are made on the work buffer. Emacs can manage many work buffers at once, enabling you to edit several files at the same time. You can edit buffers that hold deleted or
The Emacs editor operates much like a standard word processor. The keys on your keyboard represent input
$ emacs mydata
The GNU Emacs editor now supports an X Window System graphical user interface. To enable X support, start Emacs within an X Window System environment, such as a KDE, GNOME, or FVWM desktop. The basic GUI editing operations are supported: selection of text with
| Note |
XEmacs is the complete Emacs editor with a graphical user interface and Internet applications. The Internet applications, which you can easily access from the main XEmacs button bar, include a Web browser, a mail utility, and a newsreader. |
The Vim editor included with most Linux distributions is an enhanced version of the Vi editor. It includes all the commands and features of the Vi editor. Vi, which stands for
visual,
remains one of the most widely used editors in Linux. Keyboard-based editors like Vim and Emacs use a keyboard for two different operations: to specify editing commands and to receive character input. Used for editing commands, certain keys perform deletions, some execute changes, and others perform cursor movement. Used for character input, keys represent characters that can be entered into the file being edited. Usually, these two different functions are divided among different keys on the keyboard. Alphabetic keys are reserved for character input, while function keys and control keys specify editing commands, such as deleting text or moving the cursor. Such editors can rely on the existence of an extended keyboard that includes function and control keys. Editors in Unix, however, were designed to assume a minimal keyboard with
|
Key |
Cursor Movement |
|---|---|
|
h |
Moves the cursor left one character. |
|
l |
Moves the cursor right one character. |
|
k |
Moves the cursor up one line. |
|
j |
Moves the cursor down one line. |
|
CTRL-F |
Moves forward by a screen of text; the next screen of text is displayed. |
|
CTRL-B |
Moves backward by a screen of text; the previous screen of text is displayed. |
|
Input |
(All input commands place the user in input; the user
|
|
a |
Enters input after the cursor. |
|
i |
Enters input before the cursor. |
|
o |
Enters input below the line the cursor is on;
|
|
Text Selection (Vim) |
Cursor Movement |
|
v |
Visual mode; move the cursor to expand selected text by character. Once selected, press key to execute action: c change, d delete, y copy, : line editing command, J join lines, U uppercase, u lowercase. |
|
V |
Visual mode; move cursor to expand selected text by line. |
|
Delete |
Effect |
|
x |
Deletes the character the cursor is on. |
|
dd |
Deletes the line the cursor is on. |
|
Change |
(Except for the replace command, r , all change commands place the user into input after deleting text.) |
|
cw |
Deletes the word the cursor is on and places the user into the input mode. |
|
r |
Replaces the character the cursor is on. After pressing r , the user enters the replacement character. The change is made without entering input; the user remains in the Vi command mode. |
|
R |
First places into the input mode, and then overwrites character by character. Appears as an overwrite mode on the screen, but actually is in input mode. |
|
Move |
Moves text by first deleting it, moving the cursor to desired place of insertion, and then pressing the p command. (When text is deleted, it is automatically held in a special buffer.) |
|
p |
Inserts deleted or copied text after the character or line the cursor is on. |
|
P |
Inserts deleted or copied text before the character or line the cursor is on. |
|
dw p |
Deletes a word, and then moves it to the place you
|
|
yy or Y p |
Copies the line the cursor is on. |
|
Search |
The two search commands open up a line at the bottom of the screen and enable the user to enter a pattern to be searched for; press ENTER after typing in the pattern. |
|
/ pattern |
Searches forward in the text for a pattern. |
|
? pattern |
Searches backward in the text for a pattern. |
|
n |
Repeats the previous search, whether it was forward or backward. |
|
Line Editing Commands |
Effect |
|
w |
Saves file. |
|
q |
Quits editor; q! quits without saving. |
Although the Vi command mode handles most editing operations, it cannot perform some, such as file saving and global substitutions. For such operations, you need to execute line editing commands. You enter the line editing mode using the Vi colon command. The colon is a special command that enables you to perform a one-line editing operation. When you type the
Although you can create, save, close, and quit files with the Vi editor, the commands for each are not all that similar. Saving and quitting a file involves the use of special line editing commands, whereas closing a file is a Vi editing command. Creation of a file is usually specified on the same shell command line that invokes the Vi editor. To edit a file, type vi or vim and the name of a file on the shell command line. If a file by that name does not exist, the system creates it. In effect, giving the name of a file that does not yet exist instructs the Vi editor to create that file. The following command invokes the Vi editor, working on the file booklist . If booklist does not yet exist, the Vi editor creates it.
$ vim booklist
After executing the
vim
command, you enter Vi's command mode. Each key becomes a Vi editing command, and the screen becomes a window onto the text file. Text is displayed screen by screen. The first screen of text is displayed, and the cursor is positioned in the
Remember, when you first enter the Vi editor, you are in the command mode. To enter text, you need to enter the input mode. In the command mode,
a
is the editor command for appending text. Pressing this key places you in the input mode. Now the keyboard operates like a typewriter and you can input text to the file. If you press ENTER, you merely start a new line of text. With Vim, you can use the arrow keys to move from one part of the entered text to another and work on different
You can use the :q command to quit an editing session. Unlike the ZZ command, the :q command does not perform any save operation before it quits. In this respect, it has one major constraint. If any modifications have been made to your file since the last save operation, the :q command will fail and you will not leave the editor. However, you can override this restriction by placing a ! qualifier after the :q command. The command :q! will quit the Vi editor without saving any modifications made to the file in that session since the last save (the combination :wq is the same as ZZ ).
To obtain online help, enter the
:help
command. This is a line editing command. Type a colon, enter the word
help
on the line that opens at the bottom of the screen, and then press ENTER. You can add the name of a specific command after the word
help
. The F1 key also
As an alternative to using Vim in a command line interface, you can use gvim, which provides X Window System–based menus for basic file, editing, and window operations. To use gvim, enter the gvim command at an X Window System terminal prompt or select it from a window manager menu. The standard Vi interface is displayed, but with several menu buttons displayed across the top. All the standard Vi commands work just as they are described previously. However, you can use your mouse to select items on these menus. You can open and close a file, or open several files using split windows or different windows. The editing menu enables you to cut, copy, and paste text as well as undo or redo operations. In the editing mode, you can select text with your mouse with a click-and-drag operation, or use the Editing menu to cut or copy and then paste the selected text. Text entry, however, is still performed using the a , i , or o commands to enter the input mode.
| < Day Day Up > |