From the previous text I introduced some file manipulation and directory handling commands to you. From this text I’m going to talk about the text editors.
WHAT IS A TEXT EDITOR?
When we want to store some type of text data, we can use a text editor for that. In every Operating System there is a text editor. For Windows, it’s notepad. Like that there are few text editors used in LINUX Operating System. Below I have listed some of them,
- Vi/ Vim
Some of them have a GUI but some of them have only the terminal view. For an example Vi/ Vim has only the terminal view. But gVim, which is an extended version of Vim with a GUI.
WHAT IS Vi/ Vim?
Vi is a basic text editor supplied in LINUX. It has two modes known as the ‘insert mode‘ and the ‘command mode‘. Insert mode is used to write data to the text file. Command mode is used to give commands to the text editor.
First of all, open the terminal and input ‘vi <path/file_name>’ command and hit enter. Then it will give you the text editor window. If the file is not existing, it will create a file at the specific location. Otherwise it will open the existing file.
This the terminal view of the Vi text editor. It shows some lines with ‘~’ and at the end of the terminal it’s the path to the file from the current directory.
As I mentioned earlier, there are two modes in Vi editor. We can use the ‘Esc’ krey to move between these two modes. To go to the insert mode, hit ‘Esc’ and then ‘I’. This will get you to the insert mode, where you can type data to the file. Again to go back to the command mode, hit ‘Esc’ again. When you are at the command mode and hit ‘Esc’ so many times do nothing. Actually is a great thing. When you don’t know in which mode are you, hit ‘Esc’, now you are in the command mode for sure.
When you are in the insert mode at the bottom o the terminal, it shows –INSERT–. Now you can insert data to the file.
After you enter data to the file, hit ‘Esc’ to go to the command mode to save the file.
Now we are in the command mode and at the bottom of terminal it shows nothing. Now we can save the document. There are few keys to remember here.
- <SHIFT + ZZ> –> Save and quit.
- <:w> –> Save
- <:q> –> Quit
- <:wq> –> Save and Quit
- <:q!> –> Discard all changes and Quit.
This text editor could be very uncomfortable at the first. But with the time, you will used too the text editor and will love it.
Today I introduced a basic text editor in the LINUX Operating System. All other text editors are like the same. You can open it by the same way how we open the Vi text editor. I hope you got an idea about the Vi text editor and how to use it. Hope to come back with another interesting topic soon. Thank You!