Live data from Hacker News

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

news.ycombinator.com

221–230 of 279 posts

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

#221
post #65

Earlier quoted context omitted.

In neovim, :X (and cryptography in general) is removed https://github.com/neovim/neovim/commit/85338fe

Thanks great link. tldr: > vim encryption uses old, obsolete algorithms that are poorly implemented. Since insecure cryptography is worse than no cryptgraphy, the community voted in favor of removing all crypto.

This was in 2014. Since then, Vim has added non-obsolete encryption algorithms (some provided by libsodium), used by default.

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

#223

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]

It sounds like the "sluggish ssh connection" may have played a role here--imagine pressing ":X" like you think you should, but nothing happens, so you press enter a few times to see if the console is responsive.

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

#224
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…

> This would have just been an entry "Save if needed" in the File menu

No, the command would simply not exist because having so many commands would take up too much screen space.

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

#227

Earlier quoted context omitted.

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…

Consider a tool where its user performs actions with such speed and intent that they occur at a layer of thought that OP had to slow down and think about what they were actually doing to explain to an outside observer. How is that not peak intuitive design?

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

#228

Earlier quoted context omitted.

Thanks for bringing this up. I'm toying with either disabling it, cmap X or, mapping it down to a lower x. cmap X x 1. Does anyone see anything this could interfere with? 2. Does anyone know a better way to turn off the `:X` encryption option? Sadly, having to remap definitely dulls the shine of `:x`.

Mapping to 'x' is dangerous since on a system where you don't have your vimrc you'll get the original behavior of 'X'. Ideally you'd map 'X' to deliver a small electric shock. ;-)

  cmap X x
  :help X
> Mapping to 'x' is dangerous since on a system where you don't have your vimrc you'll get the original behavior of 'X'.

Which is still to prompt? A person could take their chances.

Besides, wouldn't that form of intentionally aversive conditioning actually boost the learning rate and create hyperassociations to the behavior your're attempting to stimulus extinct or just learn over?

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

#229
post #29

Why would it write if no changes have been made?

Vim is from an era when software was written to do exactly what you commanded it, not what you intended. It was your responsibility as a user to learn how to turn your intentions into commands.

Unfortuantely, too many modern programs are not designed to do what you commanded it and try to believe they know better than you do (which is often wrong, anyways). (The other problem is often not designed that expert users can use and can be programmed and used with other programs (e.g. using pipes).) I think that vi is better, in this way; it does do what you commanded it, and can be programmed and used with pipes, so it is better.

Nevertheless there are such thing as adding a confirmation message in case of a dangerous operation (and, if necessary, and option to disable such warnings). For example, C compilers usually have warnings, and you can disable any warnings that you do not want.

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

#230

I learned to do `:wq` after I learned that `:X` encrypts your file. When typing without really paying attention to the screen, I've twice encrypted my file with password like `cd tmp`, then saved the config file, breaking my system. After that, I switched to `:wq` (and sometimes `:w` `:q`) which is much safer against over-typing.

better alternative is to use `ZZ' then
Post reply on HN