How to edit, save, and quit without saving in the VI editor.
To quit the VI editor and save changes, perform the following procedure:
1.If you are currently in the insert or append mode, press Esc.
2.Press : (colon). The cursor will be re-displayed at the lower left corner of the screen, besides a colon prompt.
3.Type q!. This will quit the editor and all changes that were made to the document will be lost:
user@switch% cd /etc user@switch% ls user@switch% vi pam.conf user@switch%:q!
Use the following commands to write and quit the VI editor:
user@switch% cd /etc user@switch% ls user@switch% vi pam.conf user@switch%:wq
Note: ‘:w’ saves the current file, but does not exit.