How to: Edit files using Vi

First you will need to establish a terminal connection to your server with the appropriate user privileges. Follow the guide on how to do that here.

Next you need to locate the file you want to edit. You can use the change dir “cd” command and “ls” command to list the files and folders.

Once you know the path to your file you need to open the file in VI, which is the terminal text editor.

VI has two modes, command and insert. The former allows you to perform actions like save and quit and the latter allows you to edit files.

To open your file in the editor, use the following command:

vi /<filepath>/<filename>.<extension>

If the filename doesn’t exist in the path specified a new file with that file name will be created.

With the file open and contents displayed, you can press ‘i’ to enable insert mode. Pressing escape will return you to command mode where you can save your changes by typing the following command:


Click here to learn more about the various commands available in VI.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s