How do you quit the Vi editor with single keypress

2019-04-06 21:49发布

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.

7条回答
聊天终结者
2楼-- · 2019-04-06 22:17

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.

查看更多
淡お忘
3楼-- · 2019-04-06 22:21

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

查看更多
太酷不给撩
4楼-- · 2019-04-06 22:22

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

查看更多
smile是对你的礼貌
5楼-- · 2019-04-06 22:23

What's wrong with the tried and true?

:x

It's not one key press, but it's much less than :wq! which is what your question appears to truly seek.

Or is this a ViM only feature? My apologies if so.

查看更多
孤傲高冷的网名
6楼-- · 2019-04-06 22:33

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.

查看更多
叼着烟拽天下
7楼-- · 2019-04-06 22:34

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.

查看更多
登录 后发表回答