简体   繁体   English

在Windows中使用来自Git的Vimdiff时,颜色会增加

[英]The colors are jacked up when using Vimdiff from Git in Windows

I have configured Git to use Vimdiff as its diff/merge tool on a Windows machine. 我已将Git配置为在Windows计算机上使用Vimdiff作为其差异/合并工具。 It works, but the colors are messed up. 可以,但是颜色弄乱了。 First, it won't show any syntax highlighting, no matter how much I tell it to turn the syntax on and set the filetype. 首先,无论我告诉它多少打开语法并设置文件类型,它都不会突出显示语法。 Second, the colorscheme is obnoxious, but when I do :colorscheme and hit CTRL - D , I do not see the usual list of colorschemes. 其次,colorscheme是令人讨厌的,但是当我执行:colorscheme并按CTRL - D时 ,我看不到通常的colorchemes列表。 None of the default ones are there, only ones that I installed myself. 没有默认的,只有我自己安装的默认。

The weird thing is that my colorscheme is fine, and I have all the expected colorschemes available, and syntax highlighting works, when I launch Vim directly from the command prompt, ie not through Git. 奇怪的是,当我直接从命令提示符下启动Vim时(即不通过Git进行启动),我的colorcheme很好,并且我具有所有预期的可用colorchemes,并且语法高亮显示正常。

This makes it unnecessarily painful to review changes, and it is especially annoying when I'm trying to show a diff to a coworker. 这使审核更改变得不必要地痛苦,并且当我尝试向同事展示差异时尤其令人讨厌。 They are nearly unreadable. 它们几乎不可读。 This has been bothering me for months and I can't figure it out. 这困扰了我几个月,我无法弄清楚。

Is there something different about having Git start Vim from just launching Vim? 让Git从启动Vim到启动Vim有什么不同吗? How do I fix this so can get my Vims behaving consistently? 我该如何解决这个问题,才能使我的Vims始终如一?

Finally, after months, I figured it out. 终于,几个月后,我想通了。 I thought I should share my findings in case anyone else was fighting the same battle. 我认为我应该分享自己的发现,以防其他任何人在同一场战斗中战斗。

Git for Windows comes packaged with its own versions of a number of programs. Windows的Git随附了许多程序自己的版本。 Apparently, Vim is among them. 显然,Vim就在其中。 Doing a :echo $VIM shows that when Vim is started by Git, it is pointing to C:/Program Files (x86)/Git/share/vim . 进行:echo $VIM显示,当Vim由Git启动时,它指向C:/Program Files (x86)/Git/share/vim This Vim install seems different than my full Windows Vim install. 此Vim安装似乎与我的完整Windows Vim安装不同。

At this point you could solve the problem several ways, conceivably. 在这一点上,您可以想到几种解决方法。 One would be to repoint the VIM environment variable. 一种是重新指向VIM环境变量。 Instead, I changed the path above to be a symbolic link to my actual Vim install: 相反,我将上面的路径更改为实际Vim安装的符号链接:

C:\Program Files (x86)\Git\share>mklink /D "C:\Program Files (x86)\Git\share\vim" "C:\Program Files (x86)\Vim\"
symbolic link created for C:\Program Files (x86)\Git\share\vim <<===>> C:\Program Files (x86)\Vim\

Now the syntax highlighting is working, the colorscheme looks good, and it is much easier to review code. 现在语法高亮显示起作用了,colorscheme看起来不错,并且查看代码要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM