The one of the most handy tools in linux is the vi editor.We can write any text,script,code here and run through the command line in the linux environment (provided the corresponding compiler or interpreter exists in the linux system).
Now we generally use graphical editor('gedit') to write a script or code due to its comfortable feature of syntax highlighting which is not a feature of common vi editor.So to make it more user friendly linux improved it,namely created 'vim'.
Now it has the feature of syntax highlighting and many more features mixing those of gedit and vi.
Generally ubuntu does not contain vim but we can download it for free through command line
$ sudo apt-get install vim
And now we can open the editor through command-line
$ vim <filename> //we can omit filename here and give it after writing something in editor
Now as vi editor it has three modes:
3.Last line mode
In command mode we can edit,delete and do many operations.While opening vim it is always in command mode.
In insert mode we can write text on the editor and edit the text.
Last line mode is a part of command mode which is used to save the file and quit the environment of vi editor etc.
Now we move from one mode to one mode through mere keyboard
command mode -> insert mode= press 'i'
command mode ->last line mode=press ':'
insert mode -> command mode= 'Esc'
insert mode -> last line mode='Esc' then ':'
Again, for convenience we can into insert mode by pressing 'o' or 'O'
'o' -> enters into insert mode and opens a line below cursor
'O'->enters into insert mode and opens a line above cursor
whereas pressing 'i' enters into insert mode and opens a line on the cursor position.