'how can i get out of vi editor when esc won't work? [closed]
I am using vi editor for UNIX. Sometimes I am experiencing an issue with getting out of vi editor, where I go to press esc then type ":wq" or "q!" to quit, but it is not escaping. vi editor just enters weird symbols/characters and I can't get out. What do I do to escape and exit when esc won't escape?
Solution 1:[1]
There are few more commands for that apart from the one you are using
- Shift+zz to save (if modified )and exit
- :cq quit without writing
EDIT : I found some more commands that I just learned .
There are many ways to exit from vi editors, and you can use some of these commands to exit from other editors
- Press F2, this will drop you in Insert Mode, now press: q and hit enter
- another way is to press Ctrl + c or ctrl + z command to exit the vi editor forcefully.
- press ZZ (shift+z+z). it will save and exit.
- Ctrl + [ will also work like escape key.
the 3rd , and 6th command may or may not work on every system, as it depends on terminal's setting and system itself.
or you can do map certain keys to behave like escape, please refer this post , that will save you some keystrokes.
Solution 2:[2]
For me this worked: CTL + c (this is equal to ESC in your case) :wq! (to write save and quit) and then click enter
Solution 3:[3]
have you tried ESC then "ZZ"? seems to work as a last result for me.
Solution 4:[4]
This can happen when vi is started with TERM=linux. You can use the set term command to solve this problem. Set the TERM to vt100 with one of the following commands depending on the shell.
csh or tcsh: setenv TERM vt100
sh: TERM=vt100; export TERM
ksh, bash, or zsh: export TERM=vt100
vi should work without setting the terminal in kx mode(refer to this for a similar issue: https://unix.stackexchange.com/questions/86742/term-linuxxterm-vi-in-an-xterm-or-the-aaabbbbbbccddd-problem). In order to save this, add the set TERM command to ~/.vimrc file so the option is loaded when starting vi.
Solution 5:[5]
Have you tried ^z followed by "kill" the process?
Solution 6:[6]
I just had this issue with editor of command line of Git Bash and what worked was press Esc and then :q!. When I typed only q!, it did not work.
Solution 7:[7]
press the following shift + esc look at bottom left corner write the following colon included :wq
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | |
| Solution 3 | Zane |
| Solution 4 | Keith Thompson |
| Solution 5 | ewindes |
| Solution 6 | A.Alessio |
| Solution 7 | krosta |
