← Back to list

How to Exit Vim (Finally Explained)

If you’ve ever opened Vim and felt stuck, you’re not alone.

Tshenolo Mos · 2026-03-28 04:19 · 4 claps · 1.9 min read
#vim #exit #cli #linux
Open on Medium ↗
Wiki topics: 🔧 · Data Engineering 🔓 · Open Source

How to Exit Vim (Finally Explained)

If you’ve ever opened Vim and felt stuck, you’re not alone.

Many developers joke that the hardest part of Vim is figuring out how to exit it. But once you understand a few simple commands, it becomes easy.

In this guide, you’ll learn exactly how to exit Vim — quickly and confidently.

Watch the 60-Second Version

I also made a quick YouTube Short that shows this visually.

[embed]

Why Vim Feels Confusing

Vim works differently from most editors.

When you open a file, you’re not in “typing mode” right away. Instead, Vim starts in normal mode, where keys are used for commands instead of typing text.

That’s why pressing keys doesn’t do what you expect at first.

Step 1: Open a File

To open a file in Vim, run:

vim file.txt

This opens the file inside the Vim editor.

Step 2: Enter Insert Mode

To start typing, press:

i

Now you can edit the file like a normal text editor.

Step 3: Exit Insert Mode

Before running any commands, press:

Esc

This takes you back to normal mode.

Step 4: Exit Vim (The Important Part)

Here are the commands you actually need:

Save and Quit

:wq

This saves your changes and exits Vim.

Quit Without Saving

:q!

This exits Vim and discards any changes.

Save Only

:w

This saves your file but keeps Vim open.

Quit (Only if No Changes)

:q

This exits Vim only if nothing has changed.

Quick Mental Model

Think of Vim like this:

  • Esc → go back to command mode
  • : → start a command
  • w → write (save)
  • q → quit

Combine them to get what you want.

Common Mistake

If Vim refuses to exit, it usually means:

  • You are still in insert mode → press Esc
  • You made changes → use :wq or :q!

Bonus Tip

If you’re just starting out, you don’t need to learn everything in Vim.

Just remember:

  • i → start typing
  • Esc → stop typing
  • :wq → save and exit
  • :q! → exit without saving

That’s enough to survive Vim.

Final Thoughts

Vim can feel intimidating at first, but it becomes simple once you understand modes and a few commands.

Start with the basics, and you’ll get comfortable quickly.

If this helped you, consider sharing it with someone who’s stuck in Vim right now 😄

Thank you for reading this blog post. If you found the post helpful or interesting, here are a few ways you can show your support:

Your support and engagement means a lot to me as an open-source developer.


메타데이터
post_id
3a26fdc98c3e
slug
how-to-exit-vim-finally-explained-3a26fdc98c3e
url
https://medium.com/@tshenolomos/how-to-exit-vim-finally-explained-3a26fdc98c3e
canonical_url
https://medium.com/@tshenolomos/how-to-exit-vim-finally-explained-3a26fdc98c3e
author_url
https://medium.com/@tshenolomos
status
ok
fetched_at
2026-06-20 20:29:01