HP-UX 11i Systems Administration Handbook and Toolkit
Authors: Poniatowski M.
Published year: 2003
Pages: 223-225/301
Buy this book on amazon.com >>

Chapter 26. The vi Editor

The vi Editor

Regular Expression Words-of-Caution

Expressions Are Strings and Wildcards

Manual Pages for Commands Used in Chapter 26


The vi Editor

In this chapter, we'll cover the following topics:

  • Regular expressions

  • vi

Many UNIX users have a Graphical User Interface (GUI) through which they access their UNIX system. The Common Desktop Environment (CDE) is the most commonly used GUI on UNIX systems. It is based on the X Windows System and Motif, which together provide an advanced windowing environment. Chapter 14 in this book is devoted to CDE. Most UNIX GUIs provide a graphical editor. Despite the fact that these graphical editors are a standard part of most GUIs, the visual editor, vi , remains the most popular UNIX editor. With many fine graphics-based editors as a standard part of most UNIX GUIs and a plethora of editors available as part of personal computer windowing environments, why am I covering vi ? The answer is two-fold. First, not everyone using a UNIX system has access to a graphics display and may therefore need to know and use vi . Because vi comes with most UNIX-based systems and is a powerful editor, many new UNIX users end up using and liking it. Second, vi has traditionally been thought of as the UNIX editor. Few UNIX users have not used vi . This fact does not mean that it is everyone's primary editor; however, virtually all UNIX users have had some experience with vi .

Also, a line editor called ed comes with many UNIX systems. It is now seldom used because vi is a screen editor. Also available is an enhanced version of ed called ex. vi is much more widely used than either of the line editors, so I'll cover only vi in this chapter.

I'll cover the basics of using vi in this chapter. You can experiment with what is covered here, and if you really like it, you can investigate some of the more advanced features of vi . A quick reference card summarizing all the vi commands covered in this chapter is included with this book.

The following table is a list of tables in this chapter that summarize some of the more commonly used vi commands by function:

Table Number

vi Function

Expr

Regular Expressions

Introduction

Modes and Notations in vi

1

Starting a vi Session

2

Cursor Control Commands in vi

3

Adding Text in vi

4

Deleting Text in vi

5

Changing Text in vi

6

Search and Replace in vi

7

Copying in vi

8

Undo in vi

9

Saving Text and Exiting vi

10

Options in vi

11

Status in vi

12

Positioning and Marking in vi

13

Joining Lines in vi

14

Cursor Placement and Adjusting Screen in vi

15

Shell Escape Commands in vi

16

Macros and Abbreviations in vi

17

Indenting Text in vi

18

Shell Filters in vi

19

Pattern Matching in vi


Regular Expression Words-of-Caution

Regular expressions describe patterns for which you are searching. The regular expression usually defines the pattern for which you are searching using wildcards. Since a regular expression defines a pattern you are searching for, the terms regular expression and pattern matching are often used interchangably.

Let's get down to a couple of words-of-caution immediately:

  • Regular expressions are different from file-matching patterns used by the shell . Regular expressions are used by both the shell and many programs, including those covered in this chapter. The file matching done by the shell and programs such as find are different from the regular expressions covered in this chapter.

  • Use single quotes around regular expressions . The meta- characters used in this chapter must be quoted in order to be passed to the shell as an argument. You will, therefore, see most regular expressions in this chapter quoted.

HP-UX 11i Systems Administration Handbook and Toolkit
Authors: Poniatowski M.
Published year: 2003
Pages: 223-225/301
Buy this book on amazon.com >>