UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: 8.3 Edit CommandsChapter 8
The Vi Editor
Next: 8.5 Accessing Multiple Files
 

8.4 Saving and Exiting

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

ZZQuit vi, writing the file only if changes were made.
:xSame as ZZ.
:wqWrite and quit file.
:wWrite file.
:w fileSave copy to file.
:n1,n2w fileWrite lines n1 to n2 to new file.
:n1,n2w >> fileAppend lines n1 to n2 to existing file.
:w!Write file (overriding protection).
:w! fileOverwrite file with current buffer.
:w %.newWrite current buffer named file as file.new.
:qQuit file.
:q!Quit file (discarding edits).
QQuit vi and invoke ex.
:viReturn to vi after Q command.
:e file2Edit file2 without leaving vi.
:nEdit 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 CommandsUNIX in a Nutshell: System V EditionNext: 8.5 Accessing Multiple Files
8.3 Edit CommandsBook Index8.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