本文介绍了使用Vimdiff时加载不同的配色方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

执行vimdiff时如何加载其他颜色方案.

How to load a different colorscheme when doing vimdiff.

我想要这个,因为我当前的颜色方案在vimdiff中无法正确显示一些差异.例如,某些差异显示为相同的fg/bg颜色.这使得很难理解差异.因此,每次我执行vimdiff时,我都必须执行:colorscheme some_other_scheme

I want this because the my current colorscheme does not show some diffs properly in vimdiff, For. eg some diff is shown with same fg/bg color. This makes it very hard to understand the diff. So every time i do a vimdiff i have to do :colorscheme some_other_scheme

这可以在.vimrc文件中完成吗?

Can this be done in .vimrc file?

推荐答案

如果从命令行调用vimdiff,请将以下内容放入.vimrc:

If you're calling vimdiff from the command-line, put the following in your .vimrc:

if &diff
    colorscheme some_other_scheme
endif

如果您在vim中使用vimdiff,则必须使用:cnoreabbr覆盖用于启动/停止它的命令(例如diffthisdiffoff)(还有一个插件)或使用自动命令:

If you're using vimdiff from within vim, you'd either have to override the commands you use to start/stop it (e.g. diffthis, diffoff) using :cnoreabbr (there's also a plugin) or use an autocommand:

au FilterWritePre * if &diff | colorscheme xyz | endif

FilterWritePre在通过外部程序(diff实用程序)进行过滤之前被调用,并且&diff-选项由vim进入比较模式时设置(除其他外,请参见:help diff)

FilterWritePre is called before filtering through an external program (the diff utility) and the &diff-option is set by vim when it's going into diff-mode (among others, see :help diff)

我不确定该使用哪个自动命令返回到原始颜色方案.

I'm not sure which autocommand to use to return to the original colorscheme though.

这篇关于使用Vimdiff时加载不同的配色方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 14:41