Live data from Hacker News

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

news.ycombinator.com

231–240 of 279 posts

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

#232
`:cq` exits vim with exit code 1.

This is useful if you're in vim to write a git commit message and you realize don't actually want to commit. Or you're in vim from `fc` to edit a shell command and you realise you don't actually want to run it.

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

#233
post #138

Earlier quoted context omitted.

I agree that Vim's a mess, but I don't think a good GUI is unconditionally better because you'd need to cut down Vim's gigantic command set in order to make the GUI comprehensible. 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 c…

Personally, I think Sublime Text and VSCode's feature to search for a command (Cmd-Shift-P, Ctrl-Shift-P) strikes the right balance for discoverability within a large set of commands in a GUI app. I wish the feature was standard in all GUI apps. I wish macOS provided the feature for GUI apps as part of its menu bar implementation.

It does. Cmd-Shift-/ and start typing

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

#234
post #95

Earlier quoted context omitted.

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?

Show keycodes (e.g. " f" next to "open file tree" if you have the keys mapped like that)

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

#235
post #50

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`.

:wq just makes more sense to me, it’s “command: write, quit”

ZZ is just.. random?

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

#237
post #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.

Right, the moment any gui app becomes command-rich or option-rich enough, ui designers and/or their fanbase start whining about bloated ui and deleting them. Or reinventing a command line, where you couldn’t see it by accident anymore. These claims that gui could be better are cool in theory but real-world guis are underwhelming, to put it mildly.

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

#238
post #77

Earlier quoted context omitted.

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.

A good software interface must be discoverable by the user. I imply here that hardly anyone knows about ZZ because of improper design, which explains why it's not generally mentioned in tutorials. 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.

Your implication looks strange considering that ZZ is literally the first command mentioned in “The first steps in Vim / Getting out” section. Most likely it isn’t mentioned in tutorials because these are 99% copypaste medium bullshit from wannabe teachers.

https://vimdoc.sourceforge.net/htmldoc/usr_02.html#02.7

To exit, use the "ZZ" command. This command writes the file and exits.

I remember reading about it 17 years ago in this manual. Tbf, it could have been in another section back then, but that is no excuse for seeking some “easy” tutorials instead of R-ing the TFM. There must be a name for this syndrome when people look for documentation and learning materials in anywhere but the documentation and the learning materials.

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

#239

`:cq` exits vim with exit code 1. This is useful if you're in vim to write a git commit message and you realize don't actually want to commit. Or you're in vim from `fc` to edit a shell command and you realise you don't actually want to run it.

VCSs usually abort a commit if a temporary message file remains unmodified, so :q! is fine too.
Post reply on HN