r/programming • u/variance_explained • May 23 '17
Stack Overflow: Helping One Million Developers Exit Vim
https://stackoverflow.blog/2017/05/23/stack-overflow-helping-one-million-developers-exit-vim/
9.2k
Upvotes
View all comments
Show parent comment
1
u/skztr May 24 '17
In my experience, "is the buffer unmodified?" is not usually the check I want when I am typing
:wq.When I think the buffer is unmodified, I type
:q, ie: "quit, and warn me if the buffer is modified". If I'm typing "quit without saving, but I don't want to discard changes", and vim thinks "hm, this might discard some changes", then that's a situation that I don't want to silently "correct", it's a situation that I want to actively investigate. Did I make a change that I don't remember? Do I have some bugfix in this file that I need to remember to raise separately from the main work I'm doing?Meanwhile, if I'm typing
:wq, that means "quit, after writing the current contents of the buffer to disk". When I say "write the current contents of the buffer to disk" I damn well don't mean "maybe write the current contents of the buffer to disk, based on whether you think it would make a difference", but I damn well do mean "I don't want to lose the state that I currently have in front of me." Yes, these are often equivalent, but vim isn't keeping track of the contents on disk at this point, only the "is buffer modified since I last read it?" flag. In any situation where I think I should write to disk, but vim doesn't, we really can't be certain as to the state of any build, either - it's not like vim knows more than me about what state of a file was last used for a build / not like it's checking, so either of us could be right at that point.Either way: worst-case scenario if I write unnecessarily: a longer-than-usual build; worst-case scenario if vim is wrong about the buffer's state vs the disk's state: lost work.
I'll continue to type
:wqwhen I think I want to write, and:qwhen I don't.