Sunday, June 24, 2012

Re: How to tell if highlight has been defined

On Sunday, June 24, 2012 7:53:11 PM UTC-5, Richard wrote:
> Consider the highlight
>
> :hi MyHi ctermbg=46 guibg=#00ff00
>
> In a script, is it possible to test whether or not its
> been defined.
>
> If one uses:
>
> :hi MyHi
>
> it will produce an Error message or the highlight terms.
> What is want is something like:
>
> if ! defined_highlight("MyHi")
> :hi MyHi ....
> endif
>

Maybe use :try ... :catch to try getting the highlight info if it exists, and catch the error if it does not.

:help :try
:help :catch

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment