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
Existenceblinks2 replies#
I also have a funny related thing to Tell HN:

`git --amend` -> `:wq` is shorter and faster to type than
`git --amend --no-edit`

freeCandy1 reply#
`ce` if you have fugitive
Existenceblinks#
Not going to beat `wq` on keyboard position without yet another thing (alias) in existence to maintain.
a3w1 reply#
I often have the variant with --amend --no-edit in my bash history, so that I press up about two or three times instead of writing anyting at all.
Existenceblinks#
I'm thinking if you are joking or not! You press arrow 3 times + hope it hits whereas `:wq` 3 chars with 100% certainty.
kens1 reply#
Is there a good way to manage saved-but-not-exited vim windows so I don't open the same file twice? I keep running into a problem where I'm editing a dozen files, and then I try to re-open a file I already have opened. Vim gives me a warning about this but my choices are a) tab through all my open windows until I find the right one, or b) open a new editing window and hope that I didn't have unsaved changes in the first one.

Is there a way to have vim just go to the open window? Or is there a better way to manage my windows?
(I'm using MacVim if it makes a difference.)

aidenn01 reply#
setting "nohid" will cause vim to close non-active buffers, so at least then you only need to tab through active buffers. If I run into this situation, I just close all of my open vim windows, saving as needed, but you might have a good use case for many open vim windows.
kens#
Thanks for the suggestion! I also found that MacVim has tabs, which may be better than having a bunch of open windows.
tomcam#
WHAT

My life just began again. Thank you

waych1 reply#
I almost exclusively exit vi using CTRL_W-CTRL-Q.

It's a 3 finger chord that I use all the time to close vi windows. Makes sense that I'd use it to close the last one too.

vostok1 reply#
You might as well use emacs at that point.
waych1 reply#
Been using vi for just over 25 years now. The only thing I know how to do in emacs is exit :D vi uses the ctrl key a ton if you know what you are doing.
manaskarekar#
Ctrl-W based shortcuts are especially very useful.

Load more comments