Linux vi arrow keys broken in insert mode

左心房为你撑大大i 提交于 2019-12-17 08:06:38

问题


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?


回答1:


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




回答2:


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.




回答3:


: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 ":"




回答4:


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.




回答5:


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



回答6:


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




回答7:


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.




回答8:


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




回答9:


You might also want to try 'noesckeys'




回答10:


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



回答11:


In the command line write this:

EXINIT="set nocompatible"; export EXINIT


来源:https://stackoverflow.com/questions/812973/linux-vi-arrow-keys-broken-in-insert-mode

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!