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.
In case you need to exit Vim in easy mode (while using -y
option) you can enter normal Vim mode by hitting Ctrl + L and then any of the normal exiting options will work.
I got Vim by installing a Git client on Windows. :q
wouldn't exit Vim for me. :exit
did however...
The question has been asked here.
The q
command with a number closes the given split in that position.
:q<split position>
or :<split position>q
will close the split in that position.
Let's say your Vim window layout is as follows:
-------------------------------------------------
| | | |
-------------------------------------------------
| | | |
| | | |
| Split 1 | Split 2 | Split 3 |
| | | |
-------------------------------------------------
If you run the q1
command, it will close the first split. q2
will close the second split and vice versa.
The order of split position in the quit command does not matter. :2q
or :q2
will close the second split.
If the split position you pass to the command is greater than the number of current splits, it will simply close the last split.
For example, if you run the q100
on the above window setup where there are only three splits, it will close the last split (Split 3).
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-cEnterEntervi
EnterCtrl-\Ctrl-n:qa!
Enter
This should get you out most of the time.
Some interesting cases where you need something like this:
i
Ctrl-ovg
(you enter insert mode, then visual mode and then operator pending mode)
Qappend
Enter
i
Ctrl-ogQ
Ctrl-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:
vi
Enter: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
vi
EnterEscEscEsc:qa!
Enter