- Choosing an Editor
- Starting pico and Dabbling with It
- Saving in pico
- Cutting and Pasting Text Blocks in pico
- Checking Spelling in pico
- Getting Help in pico
- Exiting pico
- Starting vi and Dabbling with It
- Saving in vi
- Adding and Deleting Text in vi
- Importing Files into vi
- Searching and Replacing in vi
- Exiting vi
- Starting emacs and Dabbling with It
- Using emacs Menus to Spell-Check
- Saving in emacs
- Exiting emacs
Starting vi and Dabbling with It
Before you go running off to use vi, understand that it has two modes (both of which look pretty much like Figure 4.11):
- Insert mode (sometimes called input mode), in which the keys you press actually show up in the file that you're editing. You use this mode to add or change text.
- Normal mode (sometimes called command mode), in which every keystroke is interpreted as a command. You use this mode to do everything except enter text.
Figure 4.11 The vi editor inundates you with tons of onscreen help and advice, as shown here. Well, documentation is available, but the vi interface itself isn't really helpful at all!
What's confusing for many people about vi is that it starts you in command mode, meaning that if you just start typing, you may see some blank spaces, characters, and bits of words that you type—essentially, a bunch of garbage that does not exactly represent what you're typing—and you'll hear a lot of beeping. So, as we'll show you in the following steps, you'll need to access the input mode as soon as you start vi.
To start vi:
At the shell prompt, type vi. The program starts up and you'll see something like Figure 4.11. The ~ symbols show blank lines below the end of the file.
Type i to get into input mode. This itself is a command issued in command mode, so it won't show up on the screen.
hairy spiders lurk
In input mode, type anything you want.
Everything you type will show up on the screen until you return to command mode by pressing . When you are in command mode, you can use the arrow keys to navigate up and down in the file line by line and use and to scroll one screen forward and backward, respectively.