There is a big problem with vi editor. When I was attempting to use a vi editor in insert mode I was unable to use arrow keys to move cursor up and down. It responses in printing the characters A to D.
Maybe the best way to handle this is to install vim cause you are using the very limited and strict original vi.
In vi, you cannot use arrows to navigate into your code, you are using the letters:
h, j, k, l ...