# 4.2 Text Editor: VIM The ```vi``` editor is the most popular and classic text editor in the Linux family. Below, are some reasons which make it a widely used editor – - It is available in almost all Linux Distributions - It works the same across different platforms and Distributions - It is user-friendly. Hence, millions of Linux users love it and use it for their editing needs Nowadays, there are advanced versions of the ```vi``` editor available, and the most popular one is ```vim``` which is ```vi``` Improved. Some of the other ones are Elvis, Nvi, Nano, and Vile. It is wise to learn vi because it is feature-rich and offers endless possibilities to edit a file. (en beschikbaar op alle linux servers) During the exam I highly suggest you use ```vim``` this will put syntax highlighting in most Linux config files, and this will make it very obvious when you made a mistake or did not finish the config. ### Navigation in ```vi``` Let's try some small vim commands. ```vim /media/onthegenealogyofmorality``` Right now you can navigate the text files with: |action|key|pro key| |:-|:-|:-| |up |up arrow|k| |down |down arrow|j| |left |left arrow|h| |right|right arrow|l| Navigate the file using the key schema you wish to learn. - ```shift-g``` to go to bottom of file - ```gg``` to top of file ### Editing a file in ```vi``` In ```vi``` we need to go from command (navigation) mode to insert mode, this is done with the ```a``` or ```i``` button where: - a = append - i = insert Let's just use append for now, navigate to the bottom of the file and let's add some text. press ```shift-g```
press ```a```
Type some text that you like
Press ```esc```
The ```esc``` moves you out of append mode back to command mode.
### Saving ```vim``` Files Now we want to save the file. |command|effect| |:-|:-| |:w|Write changes| |:q|Quit file| |:q!|Quit file and throw away changes| |:wq!|Write Quit and force save| Type ```:w``` to save and press enter.
Then type ```:q``` to quit.
Or just type ```:wq``` to do both at the same time.
This is enough for now. However, if you want to become a VIM GENIOUS!
[www.vimgenius.com](www.vimgenius.com/) VIM is not only a text editor, it's a full blown development tool and even in new tooling like visual studio code you can select vim as an editor. It is an amazing tool! PS. If you like games, try this out: [vim_game](https://vim-adventures.com/)