6.1. VIM ( VI Improved )¶
VI or VIm is a very popular editor. It may not be available out of the box on Windows, but hey, how many Windows user actually used an editor? Traditional Windows user would work more on an IDE/GUI rather than working on/with an editor. But it is available and installed by default on most of the non Window systems. Even small systems like the Raspberry Pi have this editor installed by default in most of their configurations.
Unfortunately there is a small learning curve involved while using this editor. Once you have successfully passed this small learning curve, you can empower yourself to use this editor for your basic use, and you can eventually build up the mastery and expertise on all the features this powerful editor has to provide.
The first thing that you need to know about VIm editor is that it works on multiple modes.
normal mode / command mode
In this mode you are not editing the file, but you are giving different commands.
insert mode
In this mode you are actually editing the file. To move out of this mode press ESC key
6.1.1. Opening a new File¶
Most of the time dentinal close itself would have opened the vim editor and the file is already opened for you. But in case you want to use the vim editor to open a file, run the command vim and pass the command line argument, as file name.
e.g.:
vim /path/to/the/file
6.1.2. Editing an already open file¶
To edit the current file, navigate to the place where you want to make the modifications [1], and press the i. (i
is for Insert.) Once you are done, press ESC to move out of the Insert Mode and enter the Normal Mode.
6.1.3. Saving a new File¶
To save the file, press ESC to move out of the Insert Mode and enter the Normal Mode, then key in :w. The moment you press :, you will see :
in the command bar at the bottom view. Key in w and press Return to save the current open file.
6.1.4. Exit the editor¶
To exit the editor press ESC to move out of the Insert Mode and enter the Normal Mode, then key in :q. The moment you press :, you will see :
in the command bar at the bottom view. Key in q and press Return to quit the editor.
If you have some local changes, VIm would warn you. If you want to save changes and quit, press :wq, write and quit. If you don’t want to save, but assert that you want to quit any way, the command is :q!.