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?
Press Esc to enter Command mode, and then type :wq to write and quit the file. The other, quicker option is to use the keyboard shortcut ZZ to write and quit. To the non-vi initiated, write means save, and quit means exit vi.
In Normal Mode , you can also press ZZ or ZQ to quit Vim. Where ZZ is the same as :x and ZQ is the same as :q! . Here, ZZ and ZQ are considered commands of Normal Mode while :x and :q! are Ex commands.
For me this worked: CTL + c (this is equal to ESC in your case) :wq! (to write save and quit) and then click enter
There are few more commands for that apart from the one you are using
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With