Press the escape key (esc on some machines) to make sure you are in command mode (also called edit mode). In command mode type "ZZ" or ":wq". If you want to exit without saving changes, use ":q!".

FAQ category: