Linux vi 箭头键在插入模式中断开

我的箭头键在家里的插入模式下不能在 vi 中工作,它们只是每个插入一个换行符和一个大写字母,比如‘ A’。有办法解决吗?

68624 次浏览

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.

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.

You might also want to try 'noesckeys'

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.

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

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

In the command line write this:

EXINIT="set nocompatible"; export EXINIT

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

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

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

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