Tag Archives: vi

Vim: How to create, save and exit a file

Vim has a reputation as a difficult file editor. However it’s quite easy once you know how to use it. This quick tutorial steps through how to create, save and exit a file using Vim and it only takes 5 minutes to step through.

To create a new file using Vim, type the following into your terminal:

vi newfile

You will now see a screen similar to the one below.

The first thing we need to do is enter insert mode. This will allow us to enter text into our file. To enter insert mode press i

Notice at the bottom of the screen it now says insert.

We can now add some text into our file, type hello world.

Now we want to save our file but to do this we first need to exit insert mode. You can do this by pressing Esc.

Notice that the insert at the bottom of the screen is gone. Now type :wq!  (w is for write and q is to quit) and then click enter.

That’s it! You have now created, edited and saved a file using Vim.