Hold shift and press Z twice will also close and save. It's only three key presses instead of 4 for :x (shift + ; + x + enter)
Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
161–170 of 279 posts
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#162Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#163See, 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…
both :xa and :wqa work for this though.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#164I 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.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#165Earlier 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…
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
#166I 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 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
#167Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#168Earlier 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.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#169Earlier 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]
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.”