Exiting Vim can be a bit tricky for beginners, but here are three common ways to do it:

  1. Save and Quit:
    • Press Esc to ensure you’re in normal mode.
    • Type :wq and press Enter.
    • This command saves your changes (:w) and quits Vim (:q).
  2. Quit without Saving:
    • If you don’t want to save your changes, you can force quit Vim without saving.
    • Press Esc to ensure you’re in normal mode.
    • Type :q! and press Enter.
    • This command quits Vim without saving changes.
  3. Cancel and Quit:
    • If you’ve made changes but decide not to save them, you can cancel and quit Vim.
    • Press Esc to ensure you’re in normal mode.
    • Type :q and press Enter.
    • If Vim prevents you from quitting due to unsaved changes, you can force quit by appending !.
    • Type :q! and press Enter.

Remember, Vim has different modes, so ensure you’re in normal mode (Esc) before executing these commands.