Linux vi arrow keys broken in insert mode

Viewed 67954

My arrow keys don't work in vi in insert mode at home, they just each insert a newline and a capital letter, like 'A'. Is there a way to fix that?

12 Answers

I presume you're using vim as this is tagged as Linux. Try:

:set nocompatible

(You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.)

Ubuntu ships default with vim-tiny, which doesn't have all the bells and whistles that vim has.

Do a quick sudo apt-get install vim to get all the juicy features that everyone's talking about.

vi does not support arrow keys in insert mode. Use vim. Although your vi may just be a link to vim, it may be configured to behave like the "original" vi and thus disables the arrow keys. Just invoke vim directly.

In WSL integrated terminal on VS Code, update the package and install the full package of vim worked for me.

sudo apt-get update
sudo apt-get install vim

However, to make the arrow key works when I use conemu I have to add :set term=builtin_ansi on ~/.vimrc

echo ':set term=builtin_ansi' >> ~/.vimrc
Related