Live data from Hacker News

Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

news.ycombinator.com

31–40 of 279 posts

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#33

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

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

Why, it's super obvious. Put vim to sleep.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#35
I learned to do `:wq` after I learned that `:X` encrypts your file. When typing without really paying attention to the screen, I've twice encrypted my file with password like `cd tmp`, then saved the config file, breaking my system.

After that, I switched to `:wq` (and sometimes `:w` `:q`) which is much safer against over-typing.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#37

Shift Z Z will instantly save and exit, same as wq!

I just tried this and I think that in 40ish years of typing on computer keyboards, this is the most difficult thing I've ever typed. And I use emacs.

What do you mean? Super easy and fluid, I've been doing it for about a decade. Left pinky on left shift, left middle finger (you could try ring I suppose) on zz, tap twice.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#39

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

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

I always thought of it as an "easy enough to type but hard enough to never cause an accidental quit" mapping.

Re: Tell HN: Vim users, `:x` is like `:wq` but writes only when changes are made

#40

Why would it write if no changes have been made?

Its one of the things about exiting Vim. If you type :q, and there are unsaved changes it will prompt you to save it first and not let you quit.

So most people do :wq so that it saves and then quit or do :q! to quit without saving changes. Most people stop using :q.

Post reply on HN