brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: Vim's :wa saves every changed buffer and :wqa saves them and quits

Vim
~/tips/tip-vim-wqa-wa-save-all-buffers

:wa

Writes all modified buffers to disk in one command, and optionally exits Vim.

With a handful of files open, saving them one by one is how a change gets lost. Vim has a command for all of them.

:wa
:wqa
:xa

:wa (:wall) writes all changed buffers. :wqa (:wqall) writes them and then exits, and :xa does the same. Use :wa when you want to keep working and :wqa when you are done.

There is a safe habit hiding here: run :wa before a risky step, like a build or a :! command that reads the files from disk.

The manual lists the limits. :wa gives an error for buffers that have no file name, and buffers that are read-only are not written. Add a bang, :wa!, to write read-only ones too, but unnamed buffers still cause an error.

The caveat is that :wqa refuses to quit when a buffer has no file name, is read-only or cannot be written for another reason. That is annoying, but it is Vim protecting you. The opposite, :qa!, exits without saving, and any changes to buffers are lost, so do not type it out of habit. If you want a prompt instead of a refusal, :confirm wqa asks about the buffers that cannot be written.

Further reading: Vim help: editing.txt, writing and quitting

Going deeper: Guide: advanced tmux, a config that grows with you, formats, layouts and more

More Vim tips :%s/<Ctrl-r><Ctrl-w>/newname/g /oldname find . -name "*.conf" | vim – vim --clean file.txt :set textwidth=72 All Vim tips (45) All topics

Link