Automatic save
Save yourself from accidentally losing your work
I compulsively and habitually :wq but was convinced recently to add automatic save to my configuration. It’s a pretty common feature for pre-built configurations so if you’re switching from one of those to a custom config it’s probably something you’re used to and will want.
Vim has two settings for auto saving: autowrite and autowriteall.
I use autowriteall. It saves on all navigation commands — in particular, upon quitting.
So I have this line in my config.
-- autosave
vim.o.autowriteall = trueautowrite saves on a smaller set of navigation commands and is “vi compatible.” If you’re reading this you probably don’t need it unless you’re building a configuration that you want to be usable on whatever godforsaken prod box you find yourself logged into.
The other thing you might want to do in this area is remap :Q to :q and :Wq to :wq. I don’t, because I’m a masochist, but that remap will probably save you a bunch of complaining about how :Wq is not a real command.

