简体   繁体   English

在vim中突出显示

[英]Highlighting in vim

I'm writing my own vim theme and use this function to speed things up 我正在编写自己的vim主题,并使用此功能加快处理速度

fun <sid>hi(group, guifg, guibg, ctermfg, ctermbg, attr)
  if a:guifg != ""
    exec "hi " . a:group . " guifg=#" . s:gui(a:guifg)
  endif
  if a:guibg != ""
    exec "hi " . a:group . " guibg=#" . s:gui(a:guibg)
  endif
endfun

And call it with 并用

call <sid>hi("htmlTag", s:gui05, "")

But I'm curious on how the empty "" are treated. 但是我很好奇如何处理空的“”。

Since it skips the entry if it's a "", would the output of the function end up being 由于如果它是“”,则跳过该条目,因此该函数的输出最终会被

hi htmlTag guifg=#FFFFFF guibg=NONE 

where the empty string is evaluated by vim as NONE 空字符串被vim评估为NONE

or 要么

hi htmlTag guifg=#FFFFFF

Just skipped all together? 只是一起跳过?

I don't see how using that function will "speed things up", especially for your users. 我看不到使用该功能如何“加快速度”,特别是对于您的用户。

Anyway, call <sid>hi("htmlTag", s:gui05, "") will likely cause an error because of all the missing parameters. 无论如何,由于所有缺少的参数, call <sid>hi("htmlTag", s:gui05, "")可能会导致错误。

This command, which uses the right number of parameters, call <sid>hi("htmlTag", s:gui05, "", "", "", "") would obviously give you this output: 该命令使用正确数量的参数, call <sid>hi("htmlTag", s:gui05, "", "", "", "") 显然会为您提供以下输出:

hi htmlTag guifg=#FFFFFF

There's no reason whatsoever to expect your function to do anything that's not in the function itself. 没有任何理由期望您的函数执行函数本身之外的任何事情。

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

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