Use :wq to save and exit in both Vim and Neovim. If you only need the fastest safe answer, press Esc, type :wq, then press Enter. Vim remains common among developers; Stack Overflow’s 2023 survey listed Vim usage at 22.29% among respondents [source: Stack Overflow]. Neovim uses the same core save and quit commands, so your muscle memory carries over.
TLDR: In Vim and Neovim, press Esc, then type :wq and press Enter to save and exit. To quit without saving, use :q!. For example, if you edit 30 config files in a week and waste 20 seconds each time figuring out how to exit, that is 10 minutes gone on one tiny command. The two editors behave almost the same here, so learn the commands once and use them everywhere.
Core Save and Exit Commands
Vim and Neovim are modal editors. That means typing letters does not always insert text. You may be in insert mode, normal mode, or command line mode. This is useful, but it also explains why new users get stuck.
Here are the commands that matter most:
Esc— returns to normal mode.:w— writes, or saves, the current file.:q— quits the editor.:wq— saves and quits in one step.:x— saves only if changed, then exits.ZZ— saves and exits from normal mode.:q!— quits without saving changes.
The safest everyday command is :wq. It is plain, clear, and hard to misread. If you changed the file and want those edits kept, use it.
Vim vs Neovim: Is Saving Different?
No, not in the way most users care about. Vim and Neovim share the same command style for saving and exiting. If you know :wq in Vim, you know it in Neovim.
The difference is not the command. The difference is the wider editor setup. Neovim often feels cleaner for modern plugins, built in terminal use, and Lua based configuration. Vim is older, stable, and already installed on many Unix and Linux systems. But for saving files, both are almost identical.
Honestly, it feels like the exit problem gets blamed on Vim itself, when the real problem is that the editor gives almost no friendly warning to first time users. You type, nothing happens, then you panic. We have all seen someone close the whole terminal rather than learn :q.
When to Use Each Exit Command
Use the command based on what you want to happen to the file.
- You edited a file and want to keep it: use
:wq. - You opened a file just to read it: use
:q. - You made a mistake and want to discard changes: use
:q!. - You want a quick save but keep editing: use
:w. - You want fewer keystrokes: use
ZZ, but only if you are already in normal mode.
Be careful with :q!. The exclamation mark means “force it.” Vim and Neovim will not ask you twice. If you throw away a change, it is usually gone unless your system, plugin, or swap file can recover it.
Common Errors and What They Mean
If Vim or Neovim says “No write since last change”, it means you tried to quit after editing without saving. Use :wq to save and leave, or :q! to leave and discard edits.
If you see “E45: ‘readonly’ option is set”, the file may be read only. Try :w! if you have permission. If you do not, you may need to reopen the file with elevated rights, such as sudo vim filename. Do not force write system files unless you know why you are changing them.
If pressing letters only moves the cursor, you are probably in normal mode. Press i to enter insert mode. If typing commands just writes text into the file, press Esc first.
Practical Use Cases
System administrators often use Vim or Neovim to edit SSH settings, Nginx files, cron jobs, and package configs. In those cases, a clean exit matters. A half saved file can break a service. A discarded edit can waste time during an outage.
Writers and reviewers may also use terminal editors for notes, changelogs, or markdown drafts. If you handle lots of review material, tools with screenshot and bookmark features can help outside the terminal. This list of players with snapshot and scene bookmark features is useful for that kind of work.
For media teams, Vim may be used for scripts that rename files or run image jobs. The actual visual work often happens elsewhere. If you process large folders, this guide to editors for batch resizing and format conversion fits that workflow better than a terminal editor alone.
Best Habit to Build
Build one simple habit: press Esc before every save or quit command. It costs one keystroke. It prevents confusion. Then use :wq when you want to save, or :q! when you are sure you do not.
Vim and Neovim are not forgiving at first. That is annoying, but the commands are stable. Learn the small set above, and saving or exiting becomes automatic.
