Live data from Hacker News

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

news.ycombinator.com

251–260 of 279 posts

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

#251
post #82
post #46

Earlier quoted context omitted.

I always use ZZ! It’s so much more convenient to type with one hand

I really like having to use both my hands to perform an irreversible change to disk. Those extra milliseconds let me think through what I’m doing.

Irreversible? There's undo and version control.

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

#252

Earlier quoted context omitted.

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

Vim has way worse in its defaults. gqq, naturally, formats the current line.

Also g?? for… encoding the current line in ROT13.

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

#253
post #175

Earlier quoted context omitted.

So how is it different?

^C interrupts the current operation, while ^[ actually finishes the input sequence. The only practical difference I can think of is that when you entered input mode with a prefixed number, ^C ignores it. So 2iabc^C only writes `abc', but 2iabc^[ writes `abcabc'. Edit: apparently ^C also ignores abbreviations. :ab lhs rhs, then ilhs^[ writes rhs, but ilhs^C writes lhs.

Also, ^C doesn't trigger InsertLeave autocommands.

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

#255

Earlier quoted context omitted.

I use the following in my vimrc so I can just use semicolon instead. nore ; :

I like that AZERTY has colon on the lower row :) You can remap your keyboard as well.

I've thought about remapping my keyboard before (and I do use caps lock as escape), but any significant changes just mean I'll be totally confused whenever I use a regular QWERTY keyboard.

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

#256

Earlier quoted context omitted.

I use the following in my vimrc so I can just use semicolon instead. nore ; :

Sounds like a good idea. Any drawback that I don't see? Why not ; in the first place? perhaps to avoid hitting it accidentally.

It does mean you can't use any key bindings in normal mode that use a semicolon. But I don't have any that I use.

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

#257
Seriously. Just type Shift-double-z in normal mode. No colon, no fuss, no mistakes, no confusion with anything else. No need to remap in case you press shift, because you press shift on purpose. Works everywhere vim is installed, even if your dotfiles aren’t.

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

#258

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.

Oh, well that's good to know, I guess I'll stick to `:wq` whenever I use vim

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

#259

Earlier quoted context omitted.

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

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.

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

#260
post #244
post #164

Earlier quoted context omitted.

ZZ is only 3 keystrokes as opposed to 4 for :x (shift + z + z = 3 and shift + ; + x + enter = 4). It also doesn't require timing the release of shift before the press of x.

Wow! Never knew that existed. If I can undo 20 years of muscle memory, I'll use it. :D EDIT: Just tried it, and Z being right next to Shift is a deal breaker.

Switch to a German QWERTZ keyboard. That’ll also help with giving rusty muscle memory a fresh kick.
Post reply on HN