This is the first time my life has changed from just reading a Hacker News headline.
Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
231–240 of 279 posts
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#232This 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
#233Earlier 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.
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#234Earlier 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?
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#235Earlier 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`.
ZZ is just.. random?
Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#236Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
#237See, 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
#238Earlier 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.
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.