1

每次我在 vim 中打开一个文件时, :95;c 总是预先输入的。我不确定为什么最近开始发生这种情况。这是我的 .vimrc 的链接:https ://github.com/bsiddiqui/vimrc

在此处输入图像描述

4

2 回答 2

6

这几乎肯定是ANSI 转义码的一部分。我的第一个猜测是你的实际终端类型和 Vim 认为你的终端类型不匹配,它试图在屏幕上绘制你的终端误解的东西。

要查看 Vim 认为你的终端是什么:

:set term?

要查看您当前的环境认为终端是什么:

:echo $TERM

理想情况下,这些应该匹配,并且还应该匹配您实际使用的任何终端(但您没有说)。如果您使用的是 Linux 终端(例如 gnome-terminal),或者 OSX 中的 Terminal.app 或 iTerm2,xterm-256color是一个不错的选择。对于两个 OSX 终端,您可能必须在首选项中手动配置。一个好的香草起点是xterm;试试看它是否有效。

如果您使用的是 screen 或 tmux 之类的多路复用器,它们还允许您配置终端类型。一般来说,最好在终端仿真器中设置它并让该设置自行传播到 Vim,而不是显式配置它。

于 2013-06-28T21:52:11.580 回答
2

Found the offending lines in your vimrc.

" remove search highlighting with esc
nnoremap <silent> <esc> :noh<CR><esc>

and

" ; is better than :, and kj is better than ctrl-c
nnoremap ; :

If you remove the first one the behavior goes away. You can keep the second one.

The reason this happens is that vim is trying to use an ANSI escape code to color something. Well the first part of an escape code is escape. It seems that vim consumes its own escape code when it is trying to color something.

An example escape code from wikipedia is \x1b[30;1m. \x is escape. From here escape gets caught by vim and interpreted. After that the rest of the character are like its typed normally. Then the ; gets caught and gets reinterpreted as : and then 1m appears on the command line.

I think something similar happened with your vim except with a different escape code.


If you want to reproduce it your self you can use the following vimrc file. And run it with vim -u

set nocompatible
nnoremap ; :
nnoremap <silent> <esc> :noh<CR><esc>
于 2013-06-30T03:41:55.353 回答