To access the contents, click the chapter and section titles.
Complete Idiot's Guide to Linux
(Publisher: Macmillan Computer Publishing)
Author(s): Manuel Ricart
ISBN: 078971826x
Publication Date: 12/22/98
Chapter 13 Text Editing under a Shell
In This Chapter
- Using the Vim Visual Editor
- Working with XEmacs
- Running Ispell
Knowing how to use an editor under the command line is a must. The UI for most of these is usually very awkward, especially when you are coming from an environment like Macintosh or Windows. There are literally a hundred different editors available that you can install on your computer. Many have their strengths and disadvantages. In my opinion, there are two command line editors that you should learn. Why two? Because under certain systems only one or the other is going to be available, and you should be able to do your work with either.
The most popular editors are
- the Visual Editor (vi)
- Emacs
The vi is the most widely available editor on any UNIX-like operating system. For this reason alone it should be one you learn. Knowing that vi can be found in all systems is a comforting thought; you will always be able to edit files no matter what flavor of UNIX you find yourself using tomorrow.
Techno Talk: In general, when you are working with a terminal, you should be able to press the Backspace key and erase the last character. If you press Backspace and get a weird character like ^?, your terminal is not set up properly.
Typically, this configuration problem will crop up when you are working remotely through a telnet session. Fixing the problem is actually very easy with the aid of the stty program. (The stty program is actually very complicated, but you dont need to know too many details about how it worksjust enough to fix your problem.)
The stty program follows this format: stty command characters, where command is the name of the option, and characters is the characters you saw printed when you used them in the shell or the editor.
The frequently used commands are
- erase (to associate the backspace key)
- kill (to delete characters to the left of the cursor)
- intr (to interrupt a program)
- susp (to suspend a program)
For my daily work under UNIX, I use Emacs or its cousin, XEmacs. The main difference between the two editors is that vi is about 20 times smaller than Emacs. If you ever (hope you never do) need to do disaster recovery, vi will fit on a floppy; Emacs will not. In terms of features, however, Emacs has them all, and that is not an exaggeration.
An Improved Visual Editor: Vim
Linux distributions come with vi as a link to vim. Vim is an improved version of vi (see the following figure); originally the name was Vi Imitation, but that is no longer true. Vim contributes a slew of features missing from the original program, but the basic commands are the same. So if you learn the newer vim editor, youll have no trouble with vi, except that you will miss the additional features.
 You can see a graphical version of vim here running inside KDE.
Interactive Vim Tutorial
The easiest way to learn vim is to use the online tutorial. In vims case, this tutorial (a file in your system) is better and more interesting than reading a book because it is, well, an interactive tutorial. Heres how to access it.
To go through the tutorial, youll first need to copy a file to your home directory. The tutorial is just a text file with instructions on how to use vim.
To install the tutorial, copy /usr/doc/vim-4.5-2/tutor/tutor to your home directory. It is possible that the version number has been upped in your installation,, so copy it this way:
cp /usr/doc/vim*/tutor/tutor ~/
This process will put the tutorial file, tutor, in your home directory.
To start the tutorial, type the following two commands:
alberto@digital alberto]$ cd
[alberto@digital alberto]$ vim tutor
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
* W e l c o m e t o V I T u t o r - V e r s i o n 1 . 2 *
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*
**************
* Lesson 1.0 *
**************
Vim is a very powerful editor that has many commands, too many to
explain in a tutor such as this. This tutor is designed to describe
enough of the commands that you will be able to easily use Vim as
an all-purpose editor.
The approximate time required to complete the tutor is 25-30
minutes, depending upon how much time is spent with experimentation.
It is important to remember that this tutor is set up to teach by
use. That means that the student needs to execute the commands
to learn them properly.
Now, make sure that your Shift-Lock key is NOT depressed and
press the j key enough times to move the cursor so that Lesson
1.1 completely fills the screen.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As you can see, typing those commands will put you right into a vim session with the tutorial on the screen. Follow the instructions, and you are on your way. The tutorial should take anywhere from 20 to 60 minutes, depending on how many distractions (such as phone calls) occur.
|