How to exit VI editor

Q:
I am new to Linux, I opened a file in vi editor and I am confused how to exit form vi editor. Could you please help?

A:
vi editor is the most powerful editor I have ever seen. It has a lot of options and commands. You can learn all about vi editor in Linux terminal itself. Just type vimtutor and give enter. It will open a tutorial in vi editor itserlf!!!

To quit from vi editor, you just have to press esc and then :q
If you had made any changes to the text it wont quit with previous command. Here if you want to discard the changes you have made, then you have to press esc and then :q!
Or if you want to want to keep the changes you hve made, then you have to type esc and then :wq

Things you type after an esc and ':'will appear in the bottom left corner.

Enjoy using vi editor and exit from it freely :D