Earlier quoted context omitted.
Yeah, thanks for this. `:wq` is pretty fast to write. I think I will stick to it.
Or, as other have pointed out, just use `ZZ` which is even easier and equivilant to `:x`.
Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
71–80 of 279 posts
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#72Earlier 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`.
Well, in fairness, `:X` brings up a prompt, so an accidental `:X` won't seamlessly masquerade itself as `:x`. Otherwise, I feel a remap is just a valid option as any to disable it. I'm not sure there's a way (a quick skim of the docs made me think `set key=` would do it but that didn't work for me, or at least I didn't understand what it does) but either way you'd still have to add config. But again, as I say to ever…
That said, given that neovim doesn't have this feature at all makes it less of an issue to me.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#73Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#74See, 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…
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 input, and a short label. So you don't have to remember what `SPC h p ...` or all the options under `SPC f...`.. but it still helps to recall that `SPC h` is for 'help' related commands, `SPC f` for file related commands.
- emacs' magit[2][3]. Magit is so good at discoverability, that I'd rate it as the best tool for using git with. I've learned more about git from using it.
[0] https://github.com/justbur/emacs-which-key
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#75Earlier quoted context omitted.
You never accidentally used it on an unnamed buffer?
unnamed as [No Name]? both :wq and ZZ (:x) do the same: "E32: No file name"
And actual advantage here is that `ZZ` can be your "quietly quit anything" key. It'll close quickfix, locationlist, previewwindow, etc without complaining.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#76I 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.
Can't you use :q and then :x instead of :q then :wq ?
You may argue that :x is shorter, but one thing is character count and another is muscle memory distance because of mnemonic similarity between :q and :wq.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#77Keybinds (in normal mode): Shift + ZZ -> :x (save only if needed and quit) Shift + ZQ -> :q! (quit without saving)
I always preferred these over the :wq! And :q!, but for some reason seem way less popular. Most tutorials don’t even mention ZZ and ZQ.
Compare vim or its clones with any KDE application, which always has keybindings shown in menus, and always a complete list of rebindable keybindings in the settings menu.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#78I am surprised it is not already mentioned in the comments, but I personally cannot use an editor that doesn't automatically write changes when I am done typing. I just forget to save and wonder why the app I am working on did not change. So my (neo)vim setup uses a plugin like `Pocco81/auto-save.nvim`. This solves the problem mentioned by OP because I can just `:q` anytime.
Second, in a large Excel file, the auto save is constantly slowing me down because there’s a slight hang after every cell change.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#79It's quite incredible and a bit weird that today, in 2023, I can say "Yes, I knew this", despite non having used vim much since ~2012.
I would have never guessed I'd be able to recall things like this.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#80I 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.
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`.