user@localhost: vim-escape-guide
user@localhost:~/vim-guide$ cat how-to-exit-vim.txt
# HOW TO EXIT VIM # ========================================== You've entered Vim and now you can't escape. Don't panic. This guide will help you break free. ## METHOD 1: STANDARD EXIT ## ------------------------------------------ 1. Press Esc (to ensure you're in command mode) 2. Type : (colon) 3. Type q 4. Press Enter FULL SEQUENCE: Esc :q Enter NOTE: If you've made changes, Vim won't let you quit this way. ## METHOD 2: FORCE QUIT (DISCARD CHANGES) ## ------------------------------------------ 1. Press Esc (to ensure you're in command mode) 2. Type : (colon) 3. Type q! (the exclamation mark forces it) 4. Press Enter FULL SEQUENCE: Esc :q! Enter WARNING: This will discard any unsaved changes! ## METHOD 3: SAVE AND QUIT ## ------------------------------------------ 1. Press Esc (to ensure you're in command mode) 2. Type : (colon) 3. Type wq (write and quit) 4. Press Enter FULL SEQUENCE: Esc :wq Enter This will save your changes and exit. ## METHOD 4: WRITE TO A DIFFERENT FILE AND QUIT ## ------------------------------------------ 1. Press Esc (to ensure you're in command mode) 2. Type : (colon) 3. Type w filename (to save to a specific file) 4. Press Enter 5. Type :q and press Enter to quit EXAMPLE: Esc :w newfile.txt Enter :q Enter ## METHOD 5: EMERGENCY EXIT ## ------------------------------------------ If all else fails: 1. Press Ctrl + Z to suspend Vim 2. Type kill -9 %1 and press Enter OR: Simply close your terminal window (losing all changes) ## COMMON ERROR MESSAGES ## ------------------------------------------ E37: No write since last change - You have unsaved changes - Use :wq to save and exit - Or use :q! to discard changes and exit E212: Can't open file for writing - You don't have permission to write to the file - Use :w ~/filename to write somewhere else - Or use :q! to exit without saving ## VIM MODES EXPLAINED ## ------------------------------------------ Vim has multiple modes: - NORMAL MODE: For navigation and commands (default) - INSERT MODE: For typing text (enter with i, a, etc.) - COMMAND MODE: For executing commands (enter with :) - VISUAL MODE: For selecting text (enter with v) Always press Esc to return to normal mode before trying to quit. ========================================== -- End of File --
user@localhost:~/vim-guide$ whoami
user@localhost:~/vim-guide$