How do I exit the Vim editor?

后端 未结 10 2293
青春惊慌失措
青春惊慌失措 2020-11-22 02:26

I\'m stuck and cannot escape. It says:

\"type :quit to quit VIM\"

But when I type that it simply appears in the object body.

10条回答
  •  后悔当初
    2020-11-22 03:19

    This is for the worst-case scenario of exiting Vim if you just want out, have no idea what you've done and you don't care what will happen to the files you opened.

    Ctrl-cEnterEnterviEnterCtrl-\Ctrl-n:qa!Enter

    This should get you out most of the time.

    Some interesting cases where you need something like this:

    • iCtrl-ovg (you enter insert mode, then visual mode and then operator pending mode)

    • QappendEnter

    • iCtrl-ogQCtrl-r=Ctrl-k (thanks to porges for this case)

    • :set insertmode (this is a case when Ctrl-\Ctrl-n returns you to normal mode)


    Edit: This answer was corrected due to cases above. It used to be:

    EscEscEsc:qa!Enter

    However, that doesn't work if you have entered Ex mode. In that case you would need to do:

    viEnter:qa!Enter

    So a complete command for "I don't want to know what I've done and I don't want to save anything, I just want out now!" would be

    viEnterEscEscEsc:qa!Enter

提交回复
热议问题