Useful Vim Commands

This article will show you how to install vim and some of the useful commands to beginners.

Vim is one of the powerful Unix editors once you master how to use it. Vim stands for Visual Editor iMproved. To install vim kindly type the following:

sudo apt-get install vim

This will take a few seconds to minutes depending on the speed of your internet.

Now vim is installed. To create a new file with Vim you type vim filename

vim filename

It will open the file.

To write to a new file or an existing file that you have already opened, just type i to insert.

After you have added your content on the file, press the escape button to get out of insert mode and then type a full colon (I) followed by w (for write) and q (quit)!.

:wq

Others

i – insert before the cursor.

I – insert at the beginning of the line.

a – insert (append) after the cursor.

:w – write (save) the file, but don’t exit

:wq or (:x) or ZZ – write (save) and quit

/pattern – search for pattern

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »