Chapter 5. Using the vi Editor

   

Chapter Syllabus

5.1 Modes Used in vi

5.2 Starting and Stopping vi

5.3 Cursor Movement

5.4 Inserting and Deleting Text

5.5 Replacing Text

5.6 Undo and Redo

5.7 Scrolling Text

5.8 Search and Replace

5.9 Cut, Copy, and Paste

5.10 Importing and Exporting Text

5.11 Configuring vi Options

Until now you have been creating new files but had no way to edit a file. This chapter builds skill in using the vi editor, which is the most widely used editor on UNIX. The vi editor is available with every distribution of the UNIX operating system. Initially, all users of UNIX find the vi editor difficult to use. But as they become used to it, they start to like it due to its simplicity and power. It is not like common editors found on desktops with menus and screen displays. It gives you the full screen for displaying text. The bottom line is mostly used for vi commands when needed.

This editor is capable of handling multiple files simultaneously . All open files are called buffers in vi terminology. You can perform routine editing tasks within one buffer as well as across buffers. You can cut, copy, and paste text, search and replace text, export and import text to and from other files, and spell check. In addition, it is possible to configure the vi editor according to your requirements using a configuration file.

In the beginning, it is difficult to remember vi commands because there are no menus. As you continue using vi , you will soon remember these commands because they are simple. I have seen many experienced UNIX users who use vi , although other GUI-based editors are available, just because of its simplicity and power. In addition to the use of vi for general file editing, it is also used for typing email and editing the command line. You have already learned the EDITOR environment variable in Chapter 3. If you set the value of this variable to vi , all of your command line editing will use the same commands you use in vi .

This chapter does not explain all of the powers of the vi editor but provides sufficient explanation for the commonly used features. You will learn most of the file editing tasks in this chapter. We will start with vi modes and cursor movement and then move toward other text editing features.


   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net