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
tipsytoad1 reply#
:update is like :w but only writes when changes are made.

While we're at it :earlier and :later are undo/redo but instead of using an undo stack they use change points in time, so your undo history is never overwritten :)

lucb1e#
:earlier 30s is such a life saver when you've messed up the standard undo/redo order (u and ctrl+r).

I need it so rarely that I have a hard time remembering what the command was again whenever I need it. Needed it a few weeks ago, so now it's at the front of my mind again :D

messe2 replies#
You can also type ZZ (no colon) while in normal mode to exit and save.

This also appears to only write when changes have been made (according to some testing in neovim on my local machine).

Maursault3 replies#
> You can also type ZZ (no colon) while in normal mode to exit and save.

That's insane. What if you need to type the following words in all caps?

     DRIZZLE
     GRIZZLY
     BUZZARD
     PIZZAZZ
The last would make that command from normal mode particularly annoying. Unless you meant when not in input mode... duh.
messe#
"Normal mode" ≠ "Insert mode"
acupofnope#
He did say in "Normal Mode"
anthomtb1 reply#
Normal mode in vim does not have the meaning normal people associate with a normal text editor.
shiomiru#
To be fair, `normal mode' may be a vimism. Both traditional vi's and nvi's man pages refer to the vim `normal mode' as `command mode', and `insert mode' (mostly) as `input mode'. (Though :set showmode still says Insert, and `insert mode' is occasionally used on the man pages too.)
simonebrunozzi1 reply#
I became quite an advanced vim user in 1999, during my military service in Italy (I was stationed at the Ministry of Aerial Defense, and working on IT stuff).

It's quite incredible and a bit weird that today, in 2023, I can say "Yes, I knew this", despite non having used vim much since ~2012.
I would have never guessed I'd be able to recall things like this.

RMPR1 reply#
I don't know Vim, my fingers do. More seriously sometimes I'll get a question about how I did/do something, and have to sit at the keyboard and actually perform the action to be able to provide the answer.
Cardinal71671 reply#
A sure sign of a well designed tool imo
RheingoldRiver5 replies#
Really? IMO that's the sign of an extremely poorly designed tool that a lot of users have learned to use very well despite how poorly it's designed.

A tool that's designed well should have its actions all extremely intuitive, in which case one would not forget things in this manner because all of the actions would be derivable from their justifications. For example: ctrl+C is copy, and ctrl+V is the key right next to it for paste, making that not just muscle memory but also extremely easy to remember and even easier to explain: "press the the key to the right of C for paste".

Continue this thread — 5 replies

SecurityMinded1 reply#
Never liked ":wq" construct since I started to use vi, almost three decades ago. Always used ":x". Now realizing, it had a hidden benefit. Good for me.
andrewshadura1 reply#
Never liked ":x" construct since I started to use vi. Always used ":wq". Now realising, it had a hidden benefit. Good for me.
lucb1e#
So what's your hidden benefit

Load more comments