4 ms·
Keybinds (in normal mode): Shift + ZZ -> :x (save only if needed and quit) Shift + ZQ -> :q! (quit without saving)
by cmeacham98 4y ago
Keybinds (in normal mode):
Shift + ZZ -> :x (save only if needed and quit)
Shift + ZQ -> :q! (quit without saving)
- codesnik 4y agohuh. I'm using ZZ all the time, but I thought it is :wq
- cmeacham98 4y agoIt's possible it was at some point, but my local copy of vim tells me it is 'same as ":x"' in `:help ZZ`
- sodapopcan 4y agoYou never accidentally used it on an unnamed buffer?
- codesnik 4y agounnamed as [No Name]? both :wq and ZZ (:x) do the same: "E32: No file name"
- sodapopcan 4y agoSorry, unnamed AND unmodified. My bad. And actual advantage here is that `ZZ` can be your "quietly quit anything" key. It'll close quickfix, locationlist, previewwindow, etc without complaining.
- hitpointdrew 4y agoI 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.
- KMnO4 4y agoIf you’re learning Vim, command mode instructions are a LOT better because they actually show up on the screen.
- bmn__ 4y agoA 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.
- wruza 4y agoYour 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 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.
- bmn__ 4y agoYou need to make an effort to understand that RTFM is not the answer to the reproval of improper design, and shifting the goalpost from "discoverable user interface" to "looking for documentation and learning materials" does not do any favours to your argument. A possible correct solution is already given as an example in my previous post.
- wruza 4y agoI wasn’t shifting goalposts, only noted that the state of tutorials doesn’t explain much in the light of the described phenomenon. Apologies for this venture. Granted, it would be nice to see more apps using the solution you described. But personally I don’t find a list of commands in a table that much different from a list of commands in a text wrt discoverability. Another nuance discussed here https://news.ycombinator.com/item?id=34287407#34293277 https://news.ycombinator.com/item?id=34287407#34293277
- 0x45696e6172 4y agoI like to add: Shift + ZA -> :up (save only if needed without quitting.) by adding to your .vimrc: nnoremap ZA :update<CR>
- avgcorrection 4y ago> Shift + ZZ That’s a real “geez, our keymap is almost exhausted!” keybind.
- sodapopcan 4y agoI always thought of it as an "easy enough to type but hard enough to never cause an accidental quit" mapping.
- naniwaduni 4y agoIt's a vi keybind, so the keymap wasn't even that exhausted yet!
- amalgamated_inc 4y agoWhy, it's super obvious. Put vim to sleep.
- asplake 4y agoIt’s been like that since vi
- CGamesPlay 4y agoVim has way worse in its defaults. gqq, naturally, formats the current line.
- avgcorrection 4y agoI use `gq<movement (mostly paragraph)>` a lot. It’s a bit of a mouthful :p
- xigoi 4y agoAlso g?? for… encoding the current line in ROT13.
- thiht 4y agoI always use ZZ! It’s so much more convenient to type with one hand
- sshine 4y agoI really like having to use both my hands to perform an irreversible change to disk. Those extra milliseconds let me think through what I’m doing.