How to Use VI Unix Command

In this tutorial we will show you how to use the vi unix command.
VI, also known as a visual editor, is not a wysiwyg editor. That means, you can edit the text using this command, but cannot make any formatting changes, for example increasing line spacing etc.
To understand how to work with unix vi commands follow the steps given below.

Step 1 – Create text file

To start with, let’s type “sudo vi testing.txt” and hit enter. This will automatically create the text file with the name you put in.

Make a text file

Step 2 – Make changes to the visual editor

With that done, it will open up visual editor. Over here press “the i key” on your keyboard and then enter your text. It must be noted that in the visual editor, you cannot make any changes without pressing that key.
Once you have finished making the changes, press the Z key twice. This will automatically save the changes made and exit the visual editor.

Alter the visual editor

Step 3 – View the text file in contents

Now when we list the contents of the directory, you can see the text file present over here. This was possible after applying the vi unix command.

See the text file in directory contents

Step 4 – Display contents of text file

Now let’s display the contents of the text file using the cat command, and there you can see that the text we added in the file using the visual editor had been successfully added in the file.
And that’s it, by following the steps above you can learn how to use the unix vi commands.

See the contents of the text file