O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving and Exiting

Writing a file means saving the edits and updating the file's modification time.

Command

Action

ZZ

Quit vi, writing the file only if changes were made.

:x

Same as ZZ.

:wq

Write and quit file.

:w

Write file.

:w file

Save copy to file.

:n1,n2w file

Write lines n1 to n2 to new file.

:n1,n2w >> file

Append lines n1 to n2 to existing file.

:w!

Write file (overriding protection).

:w! file

Overwrite file with current buffer.

:w %.new

Write current buffer named file as file.new.

:q

Quit file.

:q!

Quit file (discarding edits).

Q

Quit vi and invoke ex.

:vi

Return to vi after Q command.

%

Current filename.

#

Alternate filename.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required