4 ms·
I always :q when I didn’t change anything. If I changed something intentionally, :wq and :x are equivalent. If I changed something accidentally, :x won’t catch
by sshine 4y ago
I always :q when I didn’t change anything.
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.
- hhjj 4y agoCan't you use :q and then :x instead of :q then :wq ?
- sshine 4y agoYes, but if I :q and it complains that the file was modified, and I decide that the change is worthwhile, :wq and :x are equivalent, since :x is only different when the file isn’t modified. 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.
- caust1c 4y agoCould alias x to wq? :-) That's what I'm doing after discovering this!
- moloch-hai 4y agoAlias x to q, I think you mean?
- pkulak 4y agoI use :x cus it's one less keystroke. And yes, I still use :q to make sure I don't save in case I changed something by mistake.
- JelteF 4y agoZZ is only 3 keystrokes as opposed to 4 for :x (shift + z + z = 3 and shift + ; + x + enter = 4). It also doesn't require timing the release of shift before the press of x.
- pkulak 4y agoWow! Never knew that existed. If I can undo 20 years of muscle memory, I'll use it. :D EDIT: Just tried it, and Z being right next to Shift is a deal breaker.
- renewiltord 4y agoIt's funny but I use q when I don't intend to change things and wq in whatever state I'm seeing them and x when I'm working on clean git state. 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.
- julesnp 4y agoI use the 'confirm' option in my vim config, that way I can always use :q and then get a prompt on what to do if a file's been changed. I also map <C-q> to :q to speed things up a bit.
- silisili 4y agoThis is precisely why I use w and q instead of x. Not knowing if it wrote is definitely not a feature I'd want.
- bigmadwolf 4y agoZQ will quit without writing anything.