简体   繁体   中英

Highlighting in vim

I'm writing my own vim theme and use this function to speed things up

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

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.

This command, which uses the right number of parameters, call <sid>hi("htmlTag", s:gui05, "", "", "", "") would obviously give you this output:

hi htmlTag guifg=#FFFFFF

There's no reason whatsoever to expect your function to do anything that's not in the function itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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