Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made
537 points`: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 commentsWhile 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 :)
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
This also appears to only write when changes have been made (according to some testing in neovim on my local machine).
That's insane. What if you need to type the following words in all caps?
The last would make that command from normal mode particularly annoying. Unless you meant when not in input mode... duh.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.
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
All comments shown.
Couldn't load more comments. Check your connection and try again.