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

Earlier comments
mzzter#
TIL that :wq is like :x

I only knew about :x. So thus far I’ve only edited with :x, and then used :q! to quit without writing the changes.

amelius1 reply#
I have a question about this. If I type ":w" and then immediately do Ctrl+Z to suspend the session, it seems that Vim is always able to save the file before the editor suspends. Is this by design? Or was I just lucky so far?

Anyway, it would be great to have a default shortcut for this combination of keys too.

GTP#
TIL that VIM has built-in encryption.
yodsanklai2 replies#
Why is it useful? I would do ZZ to quit with saving, or :q! to quit without saving.

Incidentally, I find :w to be very inefficient to type (any : command really, but there are not normally the most common operations), for such a common operation. I wonder if people remap it.

michaelmior2 replies#
I use the following in my vimrc so I can just use semicolon instead.

nore ; :

MayeulC1 reply#
I like that AZERTY has colon on the lower row :)

You can remap your keyboard as well.

michaelmior#
I've thought about remapping my keyboard before (and I do use caps lock as escape), but any significant changes just mean I'll be totally confused whenever I use a regular QWERTY keyboard.
yodsanklai1 reply#
Sounds like a good idea. Any drawback that I don't see? Why not ; in the first place? perhaps to avoid hitting it accidentally.
michaelmior#
It does mean you can't use any key bindings in normal mode that use a semicolon. But I don't have any that I use.
SuperCuber#
I remap `` to save because I like to obsessively spam it after every couple edits.

Fun fact, ZQ quits without saving, like :q!

Load more comments