I will explain how to install vim. Install vim using the apt command. Run with administrator privileges using sudo.
sudo apt install -y vim
Difference between vim and vi in Ubuntu
By default on Ubuntu, vi is assigned the editor vim-tiny, which limits the functionality of vim.
In the edit mode of vi, the up / down / left / right keys cannot be used and it is displayed as "A B C D" because vi is vim-tiny.
In this case, install vim as described above and vim will be assigned to vi.
(Confirmed on Ubuntu 18)