Most Unix Based Operating Systems has an editor which it is built with. It is very useful for editing text files, building shell scripts and other things which is required of a text editor.
I am Martins Ngene. I am a Software Engineer, Blogger and Technical Writer. I will give you a little content to help you get started using vi editor.
This is the default editor that comes with most of the Unix-based operating systems. The name “vi editor” is the short name for visual editor. In 1976 Bill Joy wrote the first code for the vi editor.
The vi editor is a terminal based editor. It is used to manipulate files directory from the command line. This means you do not have to download it as an application.
To use the vi editor, you need to have a Unix-based operating system installed on your machine. You can use git bash if you are on windows or mac.
To Open A File In Vi:
To open a file in vi use the command:
To open a file that was open before your computer crashed use the command:
vi -r filename
This is what the editor looks like, it shouldn't be too different on your machine.
There are two main modes on the vi editor. The Command mode and the insert mode.
In this mode every character typed is a command which is executed on the text file being edited. When you open the editor it is in the command mode by default.
In this mode, every character entered is added to the text file. To enter this mode click
i. Although some commands entered in the command mode can change the editor to insert mode. Use the escape key to leave the insert mode back to the command mode.
To move your cursor around in vi, use the normal arrow keys to move in their respective directions. To move your cursor with letters, use
CTRL + k to move upwards,
CTRL + j to move downwards. Change the mode to command mode and use “h” to move left and “l” to go right.
Before typing any command on the vi editor, you must first type the “:” colon character. I will list some of the basic commands which you can use to edit a text file on your machine:
Inserting Text Into A File:
Just as we discussed earlier, we can use
i to enter the insert mode on the vi editor and this enables us type characters into our text files.
Cutting Text In A Text File:
To cut text in the vi editor use the
Pasting Text Into A File:
To paste some text or a line of text which you cut from another file or document, use the
Undoing An Action:
To undo an action in the vi editor use the
u command. This command reverts your action one step backward.
To Move Cursor To The Beginning of Your Current Line:
To move your cursor to the beginning of the current line you are on, use the number
To Exit The Editor:
To exit the vi editor, use the
To Move Cursor To The End of Your Current Line:
To move your cursor to the end of your current line, use the
To Save An Edited File:
To save an edited file use the
To Save And Exit A File Simultaneously:
To save and exit a file simultaneously, use the
There you go, a handful of useful commands to get started using the vi editor. You can check out this link: Corolado State University Helpdocs for more commands in the vi editor.
Follow me for more useful content to give you precise knowledge about various technologies, tools and software in general.