如何分辨一个Vim会话当前使用的colorscheme [英] How to tell which colorscheme a Vim session currently uses

查看:332
本文介绍了如何分辨一个Vim会话当前使用的colorscheme的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以通过发出

  来设置Vim配色方案:colorscheme SCHEME_NAME 

但奇怪的是,您无法通过发出

 :colorscheme 

E471:Argument required 。我也没有看到:set 的输出中列出的颜色方案。



关于找出使用中的当前配色方案(除了手动切换主题,直到您认出它为止)?

解决方案

方式(因为颜色方案本质上是来源的vim命令的负载)。但是,按照惯例,应该有一个变量 g:colors_name ,它设置为颜色方案的名称。



因此,请尝试:

  echo g:colors_name 

如果你得到E121,它是一个不良的配色方案或者是默认的配色方案。



这样做(对于vim的最新版本):

  function! ShowColourSchemeName()
try
echo g:colors_name
catch / ^ Vim:E121 /
echodefault
endtry
endfunction



然后执行:

  :call ShowColourSchemeName()

如果它说default,请执行:colorscheme默认,看看颜色是否改变,如果他们这样做,你使用的格式不正确的配色方案,除了手动切换主题,你可以做很多。 >

变量 g:colors_name 记录在此处

 :help colorscheme 


You can set the Vim color scheme by issuing

:colorscheme SCHEME_NAME

but, oddly enough, you can't get the currently used scheme by issuing

:colorscheme

as this results in "E471: Argument required". I also don't see the color scheme listed in the output of :set.

So how do you go about figuring out the current color scheme in use (other than manually switching the themes until you recognize it)?

解决方案

There's no guaranteed way (as a colour scheme is essentially a load of vim commands that are sourced). However, by convention there should be a variable g:colors_name that is set to the name of the colour scheme.

Therefore, try this:

echo g:colors_name

If you get E121, it's either a poorly made colour scheme or it's the default one.

A shinier way of doing this is (for recent versions of vim):

function! ShowColourSchemeName()
    try
        echo g:colors_name
    catch /^Vim:E121/
        echo "default
    endtry
endfunction

Then do:

:call ShowColourSchemeName()

If it says "default", do :colorscheme default and see if the colours change. If they do, you're using a malformed colour scheme and there's not a lot you can do about it other than manually switching themes until you recognise it.

The variable g:colors_name is documented here:

:help colorscheme

这篇关于如何分辨一个Vim会话当前使用的colorscheme的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆