Vim is one of the best text editor on Linux Vim works with different modes such as visual, Insert, select, command line and Ex-mode. Following are the details on how you can perform different file operations with Vim.
Editing a file with Vim Editor
# vim /etc/hosts
As soon as you open an image with Vim it goes to the Visual mode to update the file content we need to go to the Insert mode that you can do just by pressing “i”.
you can see “INSERT” at the bottom of above image. Once you are in the Insert mode you can start adding content to the file.
Saving a file with Vim Editor
After adding content to file press ESC and then :wq. This will write to the file and exit the editor. If you just do :w and hit Enter it will write to file and keep the editor open or you can also do press ESC then write “:x” it will save the file and exit the editor.
That’s it its that easy to save a file using Vim editor. You can also checkout my post on Vim basic commands.