Lurker News
`:x` leaves the modification time of files untouched if nothing was changed.

    :help :x
        Like ":wq", but write only when changes have been made.

Comments (270) 59 threads

Show all comments

Showing thread 5 of 59

cmeacham985 replies#
Keybinds (in normal mode):

Shift + ZZ -> :x (save only if needed and quit)
Shift + ZQ -> :q! (quit without saving)

codesnik2 replies#
huh. I'm using ZZ all the time, but I thought it is :wq
cmeacham98#
It's possible it was at some point, but my local copy of vim tells me it is 'same as ":x"' in `:help ZZ`
sodapopcan1 reply#
You never accidentally used it on an unnamed buffer?
codesnik1 reply#
unnamed as [No Name]? both :wq and ZZ (:x) do the same: "E32: No file name"

Continue this thread — 1 reply

hitpointdrew2 replies#
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.
KMnO4#
If you’re learning Vim, command mode instructions are a LOT better because they actually show up on the screen.
bmn__1 reply#
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.

wruza2 replies#
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.

Continue this thread — 2 replies

0x45696e6172#
I like to add:

Shift + ZA -> :up (save only if needed without quitting.)
by adding to your .vimrc:

    nnoremap ZA :update
avgcorrection5 replies#
> Shift + ZZ

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

amalgamated_inc#
Why, it's super obvious. Put vim to sleep.
sodapopcan#
I always thought of it as an "easy enough to type but hard enough to never cause an accidental quit" mapping.
asplake#
It’s been like that since vi
CGamesPlay2 replies#
Vim has way worse in its defaults. gqq, naturally, formats the current line.
avgcorrection#
I use `gq` a lot. It’s a bit of a mouthful :p
xigoi#
Also g?? for… encoding the current line in ROT13.
naniwaduni#
It's a vi keybind, so the keymap wasn't even that exhausted yet!
thiht1 reply#
I always use ZZ! It’s so much more convenient to type with one hand
sshine1 reply#
I 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.
xigoi1 reply#
Irreversible? There's undo and version control.

Continue this thread — 1 reply