Linux vi 箭头键在插入模式下损坏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/812973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 17:16:17  来源:igfitidea点击:

Linux vi arrow keys broken in insert mode

linuxvimvi

提问by josh

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?

我的箭头键在家里的插入模式下在 vi 中不起作用,它们只是插入一个换行符和一个大写字母,如“A”。有没有办法解决这个问题?

采纳答案by Brian Agnew

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

我假设您正在使用 vim,因为它被标记为 Linux。尝试:

: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 $HOMEto check home directory path.)

(您可能希望通过向其中添加此命令来配置您的 .vimrc。如果您的主目录中尚未存在,请创建一个新的 .vimrc 文件,运行echo $HOME以检查主目录路径。)

回答by lothar

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.

vi 在插入模式下不支持方向键。使用vim。尽管您的 vi 可能只是一个指向 vim 的链接,但它可能被配置为表现得像“原始”vi 并因此禁用箭头键。直接调用vim即可。

回答by Han

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

Ubuntu 默认带有vim-tiny,它没有 vim 的所有花里胡哨。

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

快速sudo apt-get install vim获取每个人都在谈论的所有多汁功能。

回答by Han

You might also want to try 'noesckeys'

您可能还想尝试“noesckeys”

回答by errordeveloper

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

在 .vim 中切换到使用 git 后,我​​只是遇到了箭头键问题。

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

我已经安装了这个 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.

挖了一个小时后,我发现 AutoClose 插件(无论如何都不喜欢)破坏了箭头键。

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)

插件文档建议应该设置 set ttimeoutlen=100,但这对我不起作用!(使用 urxvt+screen 或 urxvt,甚至 xterm)

So I removed the plugin at the end.

所以我最后删除了插件。

回答by Raz

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

唯一对我有用的是“:set term=ansi”

回答by Stabledog

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:

另一个变化:在一些 .vimrc 更改后,这个问题出现在我身上。协调一致的搜索最终表明,我在正常模式下巧妙地重新映射 ESC 并不是一个好主意。删除它解决了问题:

" 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

回答by Soheil

In the command line write this:

在命令行中这样写:

EXINIT="set nocompatible"; export EXINIT

回答by Alexx Roche

:set term=builtin_ansi

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

为我修好了。您可以在转义模式(哔哔模式)下将其粘贴到 vim 中,也可以将其添加到 ~/.vimrc 的末尾而不带前导“:”

回答by noufal

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

在带有 Cygwin 的 Windows 8.1 中使用 vim 时,我遇到了同样的问题。

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

对我有用的解决方案是,只需在 Cygwin 终端中运行以下命令:

cp vimrc_example.vim ~/.vimrc