Debian12: Fixing hitting arrow keys adds characters in vi editor issue
To disable printing letters, enable right mouse button insert and enable backspace on pressing arrows in edit mode you can do following:
|
1 |
vi $HOME/.exrc |
(create file if it does not exist) and then add line:
|
1 2 3 |
set nocompatible set backspace=2 set mouse= |
And that’s it. Save the file by command :wq and you should be good to go.
Another cleaner way is just to install vim –
|
1 |
sudo apt-get install vim |
Now that the problem is resolved, let’s try to understand the issue here. vi as an editor has normal and insert mode. When you open a file using vi you are in normal mode. Here you can go to any line, use any arrow keys and the behavior is as expected. Now when you type “i”, you essentially go into insert mode. In this mode, vi does not expect you to go left, right, top, bottom using arrow keys. You can always do that by pressing “ESC” and going back to normal mode. Insert mode is just to add text to your file and that’s the behavior of vi.