Live data from Hacker News

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

news.ycombinator.com

161–170 of 279 posts

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

#162

Earlier quoted context omitted.

This is different from :x though

It is, but accidentally hitting capslock instead of shift when hitting the colon is extremely easy to do.

Caps Lock is that key that's best replaced with Ctrl? ;)

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

#163
post #48

See, that's why even though I'm a terminal user first and foremost, I really like the discoverability of GUIs, and that's where a good GUI is unbeatable by CLI. This would have just been an entry "Save if needed" in the File menu, right below "Save", and users would probably find it by accident while looking at the menu, even while not actively looking for new ways to save a file. (Not getting into the fact that a we…

gvim suggest :wqa for "save and quit" in the file menu, which is like ":x" but will save all changed buffers, not just the current buffer.

both :xa and :wqa work for this though.

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

#164
post #151
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.

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.

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 when changes are made

#165
post #84

Earlier quoted context omitted.

Yeah, you're right that CLI discoverability can still be good , but that's the same " can " than when talking about how "Electron apps can be responsive and fast" when putting VSCode as the prime example... yes, they can , but only with a great deal of extra effort from the devs, compared to the instantaneous visual feedback that a new entry provides on a GUI. In practice (which is what matters, ultimately), most CLI…

Slight nit-picking; maybe the distinctions are useful for this conversation: I'd use "CLI" more precisely to refer to command-line invocation of programs (using some shell like bash, fish, or powershell). For programs like vim or nano, I think "TUI" (text-based UI, or sometimes terminal UI) is more suitable. > yes, they can, but only with a great deal of extra effort from the devs, compared to the instantaneous visua…

> I'd use "CLI" more precisely to refer to command-line invocation [...] For programs like vim or nano, I think "TUI" (text-based UI, or sometimes terminal UI) is more suitable.

Agree! I also consider that distinction but didn't think of it when writing. Luckily we knew we were talking about the same thing :)

You're right about the GIMP example, but I think that just means that being a GUI program is not an automatic, free-pass guarantee to discoverability. GUIs make software capabilities more evident by the mere fact that they are there right in your line of sight, but of course it still needs a touch of good organization. But that becomes then a matter of visual design and information overload, which is a whole new area.

TUI programs can be perfectly discoverable, as any well written Ncurses app can show. I don't use many, but the first one that comes to mind is Aptitude. You can just run it and, again, most if not all of the possible actions and settings of the program are right there in front of you to explore or notice.

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

#166
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.

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 to :q to speed things up a bit.

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

#168
post #152

Earlier quoted context omitted.

I can't help but see that argument as post rationalization from people who have bee using :wq their whole life \s Been using :x from the start about 4 years ago and I never accidentally encrypted a file.

Same. Been using :x for about 20 years. Had no idea there was some similar encryption nonsense.

I've been using `rm` and `rm -rf` for as long without losing data, but I understand why some people like having a trash can. Different workflows are susceptible to different hazards.

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

#169

Earlier quoted context omitted.

If only! I was a TA for an introductory CS class that taught C++ and, in passing, vi. A hour before one assignment was due, a student showed up in a panic. “I just had it working but then the computer corrupted my file. Look! Can I have an extension?” The other TA and I smirked: What a lame excuse! We offered some generic advice about starting earlier and visiting office hours. He left in a huff. A few minutes later,…

[flagged]

He was legitimately confused and panicked and we could have been more understanding (especially since this turned out not to be a one-off thing). It’s good to be kind.

The editor thing wasn’t a big deal: a few minutes of “Beware :X! If you no longer trust vi, feel free to use emacs or nano, which are also installed on our system. They work a bit differently [details, resources]. You can write your code locally too, but if so, make sure it runs on our system with the autograder. Here are a few options for that too.”

Post reply on HN