Earlier quoted context omitted.
I have computer-literate parents and grew up in the PC era, so as a child I typed my elementary school assignments in vi. Accidentally using :X, encrypting one of my school papers, and having to completely rewrite it, was one of the slightly-traumatizing moments in my childhood. FWIW, I switched to :wq for a while but I'm back to using :x instead of :wq. I'm just very careful now. :)
I did this same thing on a large programming assignment in college. I’m 46 and can still remember the way the lab smelled and what the people sitting next to me were wearing the moment it happened.
Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
131–140 of 279 posts
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#132You can also type ZZ (no colon) while in normal mode to exit and save. This also appears to only write when changes have been made (according to some testing in neovim on my local machine).
> You can also type ZZ (no colon) while in normal mode to exit and save. That's insane. What if you need to type the following words in all caps? DRIZZLE GRIZZLY BUZZARD PIZZAZZ The last would make that command from normal mode particularly annoying. Unless you meant when not in input mode... duh.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#133`git --amend` -> `:wq` is shorter and faster to type than
`git --amend --no-edit`
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#134I have a question about this. If I type ":w" and then immediately do Ctrl+Z to suspend the session, it seems that Vim is always able to save the file before the editor suspends. Is this by design? Or was I just lucky so far? Anyway, it would be great to have a default shortcut for this combination of keys too.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#135You can also type ZZ (no colon) while in normal mode to exit and save. This also appears to only write when changes have been made (according to some testing in neovim on my local machine).
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#136I also have a funny related thing to Tell HN: `git --amend` -> `:wq` is shorter and faster to type than `git --amend --no-edit`
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#137See, 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…
> even though I'm a terminal user ... I really like the discoverability of GUIs, and that's where a good GUI is unbeatable by CLI. CLI has poor discoverability? Sure; but even on the terminal, discoverability can still be good: A couple of nice examples of discoverability in keyboard-focused programs: - emacs' which-key[0]; there's a vim port[1] too. This shows you (some) of the available keybindings for the next inp…
[1] Or a standard GUI. Emacs can be run as a GUI (not terminal).
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#138See, 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…
Just in this thread we've seen options for: close unless there are changes, discard changes and close, save and close, save if changed and close, and save with encryption and close. These would not be menu items.
In a GUI, you would have close (which would always prompt if there were changes, unless you turned it off globally), save (which wouldn't do anything if there were no changes), and perhaps some extra setting somewhere about an encryption key. Which would mean you'd lose the option to unconditionally save (useful sometimes if you have something watching the file and you're testing), and you'd have an extra dialog box which pops up sometimes. In terms of discoverability, it's unconditionally better, but it's not unconditionally better in all other ways.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#139Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#140Earlier quoted context omitted.
Make sure to see this comment about :X encrypting your file instead of exiting https://news.ycombinator.com/item?id=34288446
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.