Live data from Hacker News

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

news.ycombinator.com

271–279 of 279 posts

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

#271

Earlier quoted context omitted.

Indeed - hence the tendency towards caution over what I type I understand how it manifests... but I find it not that difficult to avoid My answer to lacking feedback isn't moving forward headstrong - it's verify the delicate combination went through fine

Everyone has different responses when things don’t work out exactly how we think they will. Ideally, we write software that doesn’t surprise us, however we choose to react.

The endless battle continues, be brave

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

#272

`:cq` exits vim with exit code 1. This is useful if you're in vim to write a git commit message and you realize don't actually want to commit. Or you're in vim from `fc` to edit a shell command and you realise you don't actually want to run it.

Agreed. I use this all the time.

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

#273

Earlier quoted context omitted.

It is, but accidentally hitting capslock instead of shift when hitting the colon is extremely easy to do.

Caps Lock is that key that's best replaced with Ctrl? ;)

I like to have Caps Lock cycle the last two used keyboard languages. A necessity when there are five designated on the keyboard!

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

#274

Earlier quoted context omitted.

:wq just makes more sense to me, it’s “command: write, quit” ZZ is just.. random?

Sure, but we're talking Vim here. Is that more random than `"0p`? Or `ctl-o`? Or `ctl-6`? Mnemonics are important for operations we only perform a few times per day or every other day or less. But we're talking about a _built-in_ mapping for an operation that is performed probably as much as 1000 times per day, give or take. Convenience beats out mnemonics here because you don't need them (if you care to use it). I a…

It’s fine, it’s vim and it’s all random, but I just can never remember ZZ so much as I can wq. That’s all

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

#275
post #259

Earlier quoted context omitted.

Only for Emacs users. Vim users generally replace it with Escape.

Why not both ;) - ESC when tapped, CTRL as a modifier key when pressed together with some other key.

Good idea! Though aborting a Ctrl-C could close a dialog window :/

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

#276
post #112

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.

I just tried it. :X asks you to enter an encryption key, then asks you to enter it again, and only continues if the keys match. And then you're still in vim and need to save your file to overwrite anything. Seems hard to do by mistake. (though I prefer ZZ)

I think i was 40 years into my usage of vi when i learned that ZQ was a thing. I bet someone else learns it right here.

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

#277
post #112

Earlier quoted context omitted.

I just tried it. :X asks you to enter an encryption key, then asks you to enter it again, and only continues if the keys match. And then you're still in vim and need to save your file to overwrite anything. Seems hard to do by mistake. (though I prefer ZZ)

I think i was 40 years into my usage of vi when i learned that ZQ was a thing. I bet someone else learns it right here.

it's me, just learned it

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

#279

`:cq` exits vim with exit code 1. This is useful if you're in vim to write a git commit message and you realize don't actually want to commit. Or you're in vim from `fc` to edit a shell command and you realise you don't actually want to run it.

Thank-you. That beats `HdG :wq` to delete everything and abort the commit.
Post reply on HN