Skip to Content
Mac OS X in a Nutshell
book

Mac OS X in a Nutshell

by Jason McIntosh, Chuck Toporek, Chris Stone
January 2003
Intermediate to advanced
832 pages
32h 40m
English
O'Reilly Media, Inc.
Content preview from Mac OS X in a Nutshell

Unix Text Editors

For years, two text editors have held equal sway in Unix culture: vi and Emacs. Not one to take sides, Mac OS X ships with both of them. The following two sections give you a whirlwind tour of both.

Tip

You don’t have to use one of these editors in order to open a text document from a Terminal window. You can instead use the open command with its -a (application-specifying) option to send the document to an Aqua text editor, such as TextEdit, like this:

% open -a TextExit 
                  somefile.txt

vi

vi is a modal editor, signifying that the meaning of what you type at any point depends entirely on what mode (context) the program is in. vi’s modes include command mode (see Section 17.4.1.2), which performs deletion, cut-and-paste, searching, and other text-editing commands, and insertion mode, which adds new text to the document through typing.

Command-line syntax

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

  • vi file

  • vi + line-number file

  • vi +/ pattern file

You can open file for editing, optionally at line n or at the first line matching pattern. (See Chapter 20 for more on pattern matching.) If no file is specified, vi opens with an empty buffer. See Chapter 25 for more information on command-line options for vi.

Command mode

Once the file is opened, you are in command mode. From here, you can:

  • Invoke an insert mode

  • Issue editing commands

  • Move the cursor to a different position in the file

  • Invoke ex commands

  • Invoke a Unix shell

  • Save or exit the current version of ...

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

Mac OS X Internals: A Systems Approach

Mac OS X Internals: A Systems Approach

Amit Singh
C++ In a Nutshell

C++ In a Nutshell

Ray Lischner
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar
Optimized C++

Optimized C++

Kurt Guntheroth

Publisher Resources

ISBN: 0596003706Supplemental ContentCatalog PageErrata