Appendix A. The vi, ex, and Vim Editors
This appendix summarizes the standard features of vi in
quick-reference format. Commands entered at the colon prompt (known as ex
commands because they date back to the original creation of that editor)
are included, as well as the most popular Vim features.
This appendix presents the following topics:
-
Command-line syntax
-
Review of
vioperations -
vicommands -
viconfiguration -
exbasics -
Alphabetical summary of
excommands
Command-Line Syntax
The three most common ways of starting a Vim session are:
vim [options]filevim [options] -cnum filevim [options] -c /pattern file
You can open file for editing, optionally at line num or at the first line matching pattern. If no file is specified, the editor opens with an empty buffer.
Command-Line Options
Because vi and ex are the same program, they share the same
options. However, some options make sense for only one version of the
program. Brackets indicate optional items.
Command-line options specific to Vim are so marked:
+[num]-
Start editing at line number num, or at the last line of the file if num is omitted.
+/pattern-
Start editing at the first line matching pattern.1
+?pattern-
Start editing at the last line matching pattern.1
-b-
Edit the file in binary mode. {Vim}
-ccommand-
Run the given
excommand upon startup. Only one-coption is permitted forvi; Vim accepts up to 10. The older form of this option,+command, is still supported. --cmdcommand-
Like
-c, but execute ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access