How to use Vi or VIM editor

I did another server migration last week and get caught once again with the confusing Vi editor. So I am going to put it here for my reference in the future.

To use vi, just simply type vi filename. That is the easiest part.

Now the hardest part is to edit and save the file. To edit, enter Esc and try to insert anything you want.

To save and exit, press Esc again and type :wq and enter.

To exit without saving, press Esc and type :q! and enter.

Memorize that! There are more commands for the Vi, you can find them at Google.