Live data from Hacker News

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

news.ycombinator.com

91–100 of 279 posts

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

#91
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 does have a menu which lists the commands next to the menu options. That's one area in which I feel neovim has regressed -having a default built-in discoverable interface. The various GUIs on offer for it seem aimed at the expert console user, rather than being an effort to bring good GUI to vim.

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

#92

Earlier quoted context omitted.

> Shift + ZZ That’s a real “geez, our keymap is almost exhausted!” keybind.

Vim has way worse in its defaults. gqq, naturally, formats the current line.

I use `gq` a lot. It’s a bit of a mouthful :p

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

#93

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.

That's a really bad affordance. It makes it possible for the user trying to do something non-destructive (only write if there are changes) to accidentally destroy and replace the file.

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

#94
post #45

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.

Thanks for this warning. Even worse for me, because my laptop keyboard has some kind of horrible encoding causing latency on the shift key, so I'm constantly doing :Wq when I type fast enough... Yeah I had the suspicion it was human error - but I've tested using a single finger for shift and w, so it's definitely the keyboard. [edit] Looks like that feature is not necessarily built in by default though.

Yeah I do that a lot. And on macos, vi decides that :Wq is an error and returns a non-zero status code on my subsequent :wq, cancelling my git commit. So I get to type the commit message again.

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

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

programs like vim and tmux desperately need a menu which just shows all available commands (including plugins), even if it’s opt-in. AFAIK no such menu actually exists in vim or neovim because of the way some of the commands are hard-coded

`:`? Or do you mean something else?

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

#97
post #71

Earlier quoted context omitted.

Or, as other have pointed out, just use `ZZ` which is even easier and equivilant to `:x`.

:q, if you didn’t make a change, is even shorter.

If you do this half the time you will have forgotten that you have edited the file and won't be able to exit

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

#98

Never liked ":wq" construct since I started to use vi, almost three decades ago. Always used ":x". Now realizing, it had a hidden benefit. Good for me.

Never liked ":x" construct since I started to use vi. Always used ":wq". Now realising, it had a hidden benefit. Good for me.

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

#99

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.

The only time it has happened to me, I saw a weird prompt and I understood right away. I had almost forgotten than `:wq` was a thing

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

#100
post #51

This is the first time my life has changed from just reading a Hacker News headline.

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.

Post reply on HN