home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

8.4 Saving and Exiting

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

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 .
: n , m w file Write lines n to m to new file .
: n , m w >> file Append lines n to m 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 vi .
:q! Quit vi (discarding edits).
Q Quit vi and invoke ex .
:vi Return to vi after Q command.
:e file2 Edit file2 without leaving vi .
:n Edit next file.
:e! Return to version of current file at time of last write.
:e # Edit alternate file.
% Current filename.
# Alternate filename.

Previous: 8.3 Edit Commands UNIX in a Nutshell: System V Edition Next: 8.5 Accessing Multiple Files
8.3 Edit Commands Book Index 8.5 Accessing Multiple Files

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System