Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ZZ also does the trick, but I always do :wq out of habit. After all, you only write and quit once per file.


ZZ is the same as :x which are both what I would normally want to do - only write if changed.

I would use :wq! to overwrite readonly files more than I would use :wq The only use case I can think of writing when not changed is if there is a process watching the file that I want to trigger.

I think the problem with teaching people how to save and quit in vim is that there are so many ways they might want to do it and nobody wants to dumb it down to a single default. It is a bit like how Zig doesn't have a simple print macro because in real code do you want your output buffered or unbuffered, etc.


ZZ and ZQ are both very nice.

On the note of saving/quitting and things not being mentioned enough, I only recently learned about :up to only save the file if there were actually changes (probably short for "update). Saves some time, especially with remote files, if you're one to save a lot and not remember if you saved recently already. I think this is closer to how emacs saving works by default. I bind space-f-s to save files, and tend to use that more than :w or similar, so in my case I just updated what that keybind did.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: