Linux vi arrow keys broken in insert mode

LinuxVimVi

Linux Problem Overview


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?

Linux Solutions


Solution 1 - Linux

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.)

Solution 2 - Linux

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.

Solution 3 - Linux

:set term=builtin_ansi

fixed it for me. You can either paste that into vim while in escape mode, (bleep mode) or add it to the end of ~/.vimrc without the leading ":"

Solution 4 - Linux

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.

Solution 5 - Linux

Yet another variation: this problem appeared for me after some .vimrc changes. A concerted search eventually revealed that my clever re-mapping of ESC in normal mode was not a good idea. Removing it solved the problem:

" this is NOT something you want in .vimrc:
" In normal mode, hitting Esc turns off search highlights:
nmap <ESC> :nohl<CR>  " Do NOT add this to .vimrc

Solution 6 - Linux

The only thing that worked for me was ":set term=ansi"

Solution 7 - Linux

I had same issue with arrow keys, but when I used did that set nocp or nocompatible then my backspace didn't work correctly

for some reason when I installed vim with sudo apt-get install vim, vi didn't had any issues with arrows or backspace anymore

Solution 8 - Linux

I just had an issue with arrow keys after switching over to use git in .vim.

I have installed this repo - https://github.com/sunaku/.vim

and after digging around for an hour, I found that AutoClose plugin (which didn't like anyway) broke the arrow keys.

The plugin docs suggest that one should set set ttimeoutlen=100, but that didn't work for me! (using urxvt+screen or urxvt, and even xterm)

So I removed the plugin at the end.

Solution 9 - Linux

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

Solution 10 - Linux

You might also want to try 'noesckeys'

Solution 11 - Linux

I had the same issue while using vim inside Windows 8.1 with Cygwin.

Solution worked for me is, just run the following command in your Cygwin terminal:

cp vimrc_example.vim ~/.vimrc

Solution 12 - Linux

In the command line write this:

EXINIT="set nocompatible"; export EXINIT

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjoshView Question on Stackoverflow
Solution 1 - LinuxBrian AgnewView Answer on Stackoverflow
Solution 2 - LinuxHanView Answer on Stackoverflow
Solution 3 - LinuxAlexx RocheView Answer on Stackoverflow
Solution 4 - LinuxlotharView Answer on Stackoverflow
Solution 5 - LinuxStabledogView Answer on Stackoverflow
Solution 6 - LinuxRazView Answer on Stackoverflow
Solution 7 - LinuxNight5talkerView Answer on Stackoverflow
Solution 8 - LinuxerrordeveloperView Answer on Stackoverflow
Solution 9 - LinuxSatria JanakaView Answer on Stackoverflow
Solution 10 - LinuxgonerView Answer on Stackoverflow
Solution 11 - LinuxnoufalView Answer on Stackoverflow
Solution 12 - LinuxSoheilView Answer on Stackoverflow