Live data from Hacker News

Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

news.ycombinator.com

181–190 of 279 posts

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#181
post #57

A lot of the pain could've been avoided if they just wrote somewhere that you need to type ':' or something else to access help/commands when inside of vi/vim

I wonder where the first place is for people to look when needing help with random commands.

    man vim
The :help command is mentioned in the second paragraph. And repeated the third. Though most people probably just use web searches anyway nowadays.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#184
post #107

Earlier quoted context omitted.

I don't know Vim, my fingers do. More seriously sometimes I'll get a question about how I did/do something, and have to sit at the keyboard and actually perform the action to be able to provide the answer.

A sure sign of a well designed tool imo

Really? IMO that's the sign of an extremely poorly designed tool that a lot of users have learned to use very well despite how poorly it's designed.

A tool that's designed well should have its actions all extremely intuitive, in which case one would not forget things in this manner because all of the actions would be derivable from their justifications. For example: ctrl+C is copy, and ctrl+V is the key right next to it for paste, making that not just muscle memory but also extremely easy to remember and even easier to explain: "press the the key to the right of C for paste".

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#185

Earlier quoted context omitted.

I think their point is sometimes their left pinky is a bit lazy and won't get off the fucking shift key

[dead]

Me either, but that's because I type `:wq!` every single time instead. I'm not one of those who is afraid of typing more than a single character so I don't care if it's actually 3 I'm hitting. I am someone whose entire brain comes to an absolute crash if I type "wq" and it's asking me if I want to save over a RO file. It's like having a belt loop or pocket catch on a door handle and I despise it.

So, `:wq!`, or as I call it "write the fucking file and quit, _with feeling_"

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#186

Earlier quoted context omitted.

I think their point is sometimes their left pinky is a bit lazy and won't get off the fucking shift key

[dead]

The only reason the footgun is there is because vim put it there. Seems reasonable to me to be frustrated by that.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#187
post #175

Earlier quoted context omitted.

That’s not the exact same as Escape.

So how is it different?

^C interrupts the current operation, while ^[ actually finishes the input sequence. The only practical difference I can think of is that when you entered input mode with a prefixed number, ^C ignores it. So 2iabc^C only writes `abc', but 2iabc^[ writes `abcabc'.

Edit: apparently ^C also ignores abbreviations. :ab lhs rhs, then ilhs^[ writes rhs, but ilhs^C writes lhs.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#189

I barely ever use vi(m), but occasionally use it when I have to or it's convenient for me to edit something at a CLI only, which in my work practice is only an occasional brief thing. `:x` is one of only like 8 commands I know! I'm surprised that it's apparently not one of the basic commands everyone knows?

It's pretty well-known (a bit less than :wq though).

What most didn't know (myself included) is that the behavior is slightly different from wq.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#190
post #68

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.

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.
Post reply on HN