Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by hhjj on Saturday January 07, 2023 @10:58AM
(#34289224)
Can't you use :q and then :x instead of :q then :wq ?
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by sshine on Saturday January 07, 2023 @11:02AM
(#34289283)
Yes, 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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by caust1c on Saturday January 07, 2023 @12:13PM
(#34290151)
Could alias x to wq? :-) That's what I'm doing after discovering this!
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by moloch-hai on Saturday January 07, 2023 @12:34PM
(#34290403)
Alias x to q, I think you mean.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by pkulak on Saturday January 07, 2023 @01:39PM
(#34291094)
I 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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by JelteF on Saturday January 07, 2023 @02:05PM
(#34291415)
ZZ 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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by pkulak on Saturday January 07, 2023 @11:16PM
(#34295956)
Wow! 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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by xigoi on Sunday January 08, 2023 @04:55AM
(#34297655)
Why not use the other Shift if that's a problem?
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by pfalke on Sunday January 08, 2023 @08:11AM
(#34298826)
Switch to a German QWERTZ keyboard. That’ll also help with giving rusty muscle memory a fresh kick.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by renewiltord on Saturday January 07, 2023 @01:48PM
(#34291210)
It'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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by julesnp on Saturday January 07, 2023 @02:09PM
(#34291475)
I 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.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by silisili on Saturday January 07, 2023 @03:12PM
(#34292171)
This is precisely why I use w and q instead of x. Not knowing if it wrote is definitely not a feature I'd want.
Re:Tell HN: Vim users, `:x` is like `:wq` but writes only wh...
by bigmadwolf on Sunday January 08, 2023 @05:05PM
(#34303689)
ZQ will quit without writing 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.