views:

840

answers:

9

Because honestly

:wq!

is just too much to type :)

Please note that the question is about original Vi (say Vi which comes with FreeBSD) not Vim.

+1  A: 

You can't.

Quitting vi

Vi Manual

I noticed this question is about productivity, why on earth would you still be sitting in the console if you want productivity? :)

Filip Ekberg
+1  A: 

Does :x work on Vi? Although for your case I guess it might be :x!

you don't need the last !, you just need to press ESC, type :wq and press Enter.
Filip Ekberg
+1  A: 

Ctrl-Z, kill %1

I know that's even more key presses, but but least you get out of vi quickly enough.

(warning: This will not save your document as :wq does. Take this as a kind of (bad) joke)

pilif
that's not equal to wq!!
Filip Ekberg
sure it's not. I was joking.
pilif
See Grunties' answer - it was funnier ;-)
Mark Brittingham
+11  A: 

Use the key marked 'power' on the front of the computer. This, however, is likely to cause some disruption to productivity in most cases.

Grunties
Oh man, you beat me to it. I was sure I'd get downvoted but I was equally sure it would be totally worth it.
Mark Brittingham
Oh, and folks, this isn't "offensive" - it is just a bit funny. That really is Ok.
Mark Brittingham
C'mon people, the offensive flag should only be used for things that are actually offensive - cursing, personal attacks, stuff like that. If you just don't like the answer, downvote it.
Graeme Perrow
Well, I hope you're all happy. By marking my one-liner as offensive you have hurt my feelings so deeply that I fear I will never recover. You may have saved small children from the assault on dignity that is a bad pun, but you've scarred me for life. (or something... what were you expecting?)
Grunties
I've noticed some people use the "spam" part of offensive as justification for "useless" responses; that's why I tend to put humor in comments (unless there's a real answer as well).
paxdiablo
+1 to help Grunties recovery. :-)
Graeme Perrow
+1 because all this discussion makes it even funnier. It's not helpful answer, but funny, so sue me :)
thomasrutter
+10  A: 

Hold down the shift key and bang on Z twice.

ZZ is (mostly) equivalent to :wq!.

If you really want a single-keystroke solution, FreeBSD comes with the source so, in a pinch, you could modify that and re-compile. It's a bit of an overkill but it'll solve your problem.

paxdiablo
And for dolzenko's edification, ZQ is (mostly) equivalent to :q! I definitely use them a lot more than :wq/:q.
ephemient
+2  A: 

What about "ZZ"? It has slightly different semantics to ":wq!", but is also slightly shorter.

Daniel Nadasi
+1  A: 

Map your favourite key to the :wq! command.

e.g. put this in your .vimrc:

map <F8> :wq!<CR>

Et voilá.

Edit: Sorry, vim only, missed that.

+1  A: 

This seems to work on solaris' old version of vi:

Version SVR4.0, Solaris 2.5.0

$ vi -c "map g ZZ" test

edit: Also, this seems to work:

$ vi -c 'map g :q!^M' test

Where ^M is actually, ^V (ctl-v) then ^M (ctl-m)

Dan McNevin
Yeah, it works, nice! Actually I already regret that I didn't state which version I want (i.e. with saving or without), so is there any way to put Enter character in mapped sequence? It would be possible to "map g :q!<Enter>" to quit without saving.
dolzenko
it seems like this works too:$ vi -c 'map g :q!^M' testWhere ^M is actually, ^V then ^M
Dan McNevin
awesome, thank you very much!
dolzenko
A: 

If you're using gvim you can close it with ALT+F4. Two keys, but one keypress.

If you're using vi in its own xterm, ALT+F4 should close the xterm, killing vi as well.

Nathan Fellman
Did you read the question? Man, it's 150 bytes only.
dolzenko