How to save edits in vim?

I use nano but it is not installed on this system. I opend the file /etc/hosts

sudo vim /etc/hosts

Made changes. How do I save files edited with vim? What keystrokes I must type. Please suggest.

I found solution in search. It said. The command to save a file in VIM and quit the editor is :wq . To save the file and exit the editor simultaneously:

  1. Press Esc key to switch to normal mode.
  2. Type :wq and press the Enter key.
  3. Another command line option to save a file and quit Vim is to type :x

You can press ESC and then hold down the Shift key and press z twice too. For future reference see my page:

Esc Shift+: add :w stay into open session, :x direct with close the session

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki