347
GUI Interfaces
349
Extended Regular Expressions
357
Improved Editing Facilities
359
Programming Assistance
365
Interesting Features
368
Sources and Supported Operating Systems
374
Part IV. Appendixes
A. The vi, ex, and Vim Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
B. Setting Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
C.
Problem Checklists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
D. vi and the Internet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447
Table of Contents | xi
Preface
Text editing is one of the most common tasks on any computer system, and vi is one
of the most useful standard text editors on a system. With vi you can create new files
or edit any existing text-only file.
vi, like many of the classic utilities developed during the early years of Unix, has a
reputation for being hard to navigate. Bram Moolenaars enhanced clone, Vim (vi
Improved), has gone
a long way toward removing reasons for such impressions. Vim
includes countless conveniences, visual guides, and help screens. It has become prob-
ably the most popular version of vi, so this seventh edition of this book devotes seven
new chapters to it in Part II, Vim . However, many other worthy clones of vi also exist;
we cover three of them in Part III, Other vi Clones .
Scope of This Book
This book consists of 18 chapters and 4 appendixes, divided into 4 parts. Part I, Basic
and Advanced vi , is designed to get you started using vi quickly, and to follow up with advanced skills that will let you use it effectively.
The first two chapters, Chapter 1, The vi Text Editor , and Chapter 2, Simple Editing ,
present some simple vi commands with which you can get started. You should practice
these until they are second nature. You could stop reading at the end of Chapter 2,
having learned some elementary editing tools.
But vi is meant to do a lot more than rudimentary word processing; the variety of
commands and options enables you to shortcut a lot of editing drudgery. Chapter 3,
Moving Around in a Hurry , and Chapter 4, Beyond the Basics , concentrate on easier ways to do tasks. During your first reading, youll get at least an idea of what vi can do
and what commands you might harness for your specific needs. Later, you can come
back to these chapters for further study.
Chapter 5, Introducing the ex Editor , Chapter 6, Global Replacement , and Chapter 7,
Advanced Editing , provide tools that help you shift more of the editing burden to the computer. They introduce you to the ex line editor underlying vi, and they show you
how to issue ex commands from within vi.
xiii
Chapter 8, Introduction to the vi Clones , provides an introduction to the extensions available in the four vi clones covered in this book. It centralizes in one place the
descriptions of multiwindow editing, GUI interfaces, extended regular expressions,
facilities that make editing easier, and several other features, providing a roadmap to
what follows in the rest of this book. It also provides a pointer to source code for the
original vi, which can be compiled easily on modern Unix systems (including GNU/
Linux).
Part II, Vim , describes Vim, the most popular vi clone in the early part of the 21st century.
Chapter 9, Vim (vi Improved): An Introduction , provides a general introduction to Vim, including where to get binary versions for popular operating systems and some of the
different ways to use Vim.
Chapter 10, Major Vim Improvements over vi , describes the major improvements in
Vim over vi, such as built-in help, control over initialization, additional motion com-
mands, and extended regular expressions.
Chapter 11, Multiple Windows in Vim , focuses on multiwindow editing, which is per-
haps the most significant additional feature over standard vi. This chapter provides all
the details on creating and using multiple windows.
Chapter 12, Vim Scripts , looks into the Vim command language, which lets you write scripts to customize and tailor Vim to suit your needs. Much of Vims ease of use out
of the box comes from the large number of scripts that other users have already written
and contributed to the Vim distribution.
Chapter 13, Graphical Vim (gvim) , looks at Vim in modern GUI environments, such
as those that are now standard on commercial Unix systems, GNU/Linux and other
Unix work-alikes, and MS Windows.
Chapter 14, Vim Enhancements for Programmers , focuses on Vims use as a program-
mers editor, above and beyond its facilities for general text editing. Of particular value
are the folding and outlining facilities, smart indenting, syntax highlighting, and edit-