bash 为什么vim在打开文件后将第一个字母更改为g

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31783160/
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-09-18 13:23:45  来源:igfitidea点击:

Why vim is changing first letter to g after opening a file

bashvimcygwin.bash-profile

提问by arenaq

When I open a file, eg vim .bashrc, vim opens the file and change the first letter to g. What I see is the following:

当我打开一个文件时,例如vim .bashrc,vim 打开文件并将第一个字母更改为g. 我看到的是以下内容:

g To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
...

I change gback to #, but after loading the file its again changed. Happens with multiple files.

我改g#,但在加载文件后再次更改。发生在多个文件中。

Last things I have done was: installig gccand make.

我做的最后一件事是: installiggccmake.

Why is this happening?

为什么会这样?

EDIT: My .vimrc file:

编辑:我的 .vimrc 文件:

set nocompatible
set backspace=indent,eol,start
set number
set tabstop=4
syntax on

采纳答案by arenaq

So it appers to be a vim issue. So far I gathered only two solutions:

所以它似乎是一个 vim问题。到目前为止,我只收集了两个解决方案:

  • Reinstall to older version of vim. i reinstalled to 7.4.752-1 and bug is gone.
  • Change cygwin terminal to anyone but "xterm*" (right-click on title bar -> Options... -> Terminal -> Type)
  • 重新安装到旧版本的 vim。我重新安装到 7.4.752-1 并且错误消失了。
  • 将 cygwin 终端更改为“xterm*”以外的任何人(右键单击标题栏 -> 选项... -> 终端 -> 类型)

回答by MrEtArn

I had the exact same problem

我有同样的问题

I found out it was a bug in my ssh client (mobaXterm).

我发现这是我的 ssh 客户端 (mobaXterm) 中的一个错误。

Updating (to mobaXterm 'personal edition v9.1') resolved the issue.

更新(到 mobaXterm 'personal edition v9.1')解决了这个问题。

回答by bearvarine

I am using vim on Ubuntu Linux 16.04 via MobaXterm version 7.7. This is an older version of MobaXterm that supports command-line-settable terminal background colors.

我通过 MobaXterm 7.7 版在 Ubuntu Linux 16.04 上使用 vim。这是一个旧版本的 MobaXterm,支持命令行设置的终端背景颜色。

The following change to my .bash_profile solved this problem for me:

对我的 .bash_profile 的以下更改为我解决了这个问题:

# Fix for Vim 8.0 bug that stomps on line 1 char 1:
export TERM=linux

回答by NirIzr

For me, I traced the issue down to the following line:

对我来说,我将问题追溯到以下几行:

set nocompatible

It is found in /usr/share/vim/vim74/debian.vim, which is included from /etc/vim/vimrcwith the line runtime! debian.vim

它位于 中/usr/share/vim/vim74/debian.vim,该/etc/vim/vimrc行包含在runtime! debian.vim

回答by Zinyth

Strange enough, but it works for me. I created a ~/.vimrc file:

很奇怪,但它对我有用。我创建了一个 ~/.vimrc 文件:

syntax on   
set background=dark

The 2nd option disable the bug.

第二个选项禁用该错误。

回答by Mhmd Salem

make sure you dont set the visual bell in your .vimrc

确保你没有在你的 .vimrc 中设置可视铃

set visualbell

in case you have it then just delete it :)

如果你有它,那就删除它:)

回答by kgeter

The exact same thing was happening to me! It wasn't occurring in gvim, so I thought maybe something was going on in my .vimrc. I zeroed-out my .vimrc but it was still happening. Only when I completely deleted my .vimrc did this behavior stop. As suggested,I rolled back to an older version (7.3.1152-1) with cygwin setup and that fixed it. I did not have to change any terminal settings, however. It makes sense because I updated cygwin yesterday, when I started seeing the errant g's.

完全相同的事情发生在我身上!它没有发生在 gvim 中,所以我想我的 .vimrc 中可能发生了一些事情。我将我的 .vimrc 归零,但它仍在发生。只有当我完全删除我的 .vimrc 时,这种行为才会停止。按照建议,我使用 cygwin 设置回滚到旧版本 (7.3.1152-1) 并修复了它。但是,我不必更改任何终端设置。这是有道理的,因为我昨天更新了 cygwin,当时我开始看到错误的 g。

回答by sDoky

I am on ArchLinux. vim 8.0.0987-1 always decreases a number upon opening a file (as if xtrl+x pressed). Downgrade to 8.0.0722-1 fixed the issue.

我在 ArchLinux 上。vim 8.0.0987-1 在打开文件时总是减少一个数字(就像按下 xtrl+x 一样)。降级到 8.0.0722-1 解决了这个问题。