Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
537 points`:x` leaves the modification time of files untouched if nothing was changed.
:help :x
Like ":wq", but write only when changes have been made.
Comments (270) 59 threads
Show all comments
Showing thread 2 of 59
If I changed something intentionally, :wq and :x are equivalent. If I changed something accidentally, :x won’t catch that, and :q complaining will require me to decide if :q! or :wq is correct.
So :x does not fit my workflow of avoiding accidental writes. Just like ZZ does not.
You may argue that :x is shorter, but one thing is character count and another is muscle memory distance because of mnemonic similarity between :q and :wq.
Continue this thread — 1 reply
EDIT: Just tried it, and Z being right next to Shift is a deal breaker.
Continue this thread — 2 replies
Honestly it sounds complex, but I don't even think about it and it only struck me reading your comment.
The warning note on q is desirable.
I also map to :q to speed things up a bit.