Title: Vi Commands - Exiting (quit, write and save)
Course: CIS 121: Linux/UNIX I: Fundamentals ~ For IGNITE Review > Section: Learning Modules

Pressing the colon : will allow you to give instructions to vi (technically speaking, typing the colon will open the ex editor). :w will write (save) the file, :q will quit an unchanged file without saving, and :q! will quit vi discarding any changes. :wq will save and quit and is the same as typing ZZ in command mode. (Source: Linux Fundamentals, Cobbaut, 150)

- :q – Exit(quit) if no changes
- :q! - Exit, do not save changes
- :w – Save file (Write to file)
- :w filename – Save to a new file
- :wq – Save and exit
- :wq filename – Save to new file and exit
- :x – Save and exit