Skip to Content
Learning the vi and Vim Editors, 7th Edition
book

Learning the vi and Vim Editors, 7th Edition

by Arnold Robbins, Elbert Hannah, Linda Lamb
July 2008
Beginner
492 pages
16h
English
O'Reilly Media, Inc.
Content preview from Learning the vi and Vim Editors, 7th Edition

Command-Line Syntax

The three most common ways of starting a vi session are:

vi [options] file
vi [options] +num file
vi [options] +/pattern file

You can open file for editing, optionally at line num or at the first line matching pattern. If no file is specified, vi opens with an empty buffer.

Command-Line Options

Because vi and ex are the same program, they share the same options. However, some options only make sense for one version of the program. Options specific to Vim are so marked:

+[ num ]

Start editing at line number num, or the last line of the file if num is omitted.

+/ pattern

Start editing at the first line matching pattern. (For ex, this fails if nowrapscan is set in your .exrc startup file, since ex starts editing at the last line of a file.)

+? pattern

Start editing at the last line matching pattern.

-b

Edit the file in binary mode. {Vim}

-c command

Run the given ex command upon startup. Only one -c option is permitted for vi; Vim accepts up to 10. An older form of this option, +command, is still supported.

--cmd command

Like -c, but execute the command before any resource files are read. {Vim}

-C

Solaris vi: same as -x, but assume the file is encrypted already.

Vim: start the editor in vi-compatible mode.

-d

Run in diff mode. Works like vimdiff. {Vim}

-D

Debugging mode for use with scripts. {Vim}

-e

Run as ex (line-editing rather than full-screen mode).

-h

Print help message, then exit. {Vim}

-i file

Use the specified file instead of the default (~/.viminfo) to save or restore Vim’s state. ...

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.
Start your free trial

You might also like

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9780596529833Errata Page