Loading ...
Sorry, an error occurred while loading the content.

41241Re: Removing a highlight group

Expand Messages
  • Klaus Bosau
    Jun 25, 2003
    • 0 Attachment
      On Tue, 24 Jun 2003, Yegappan Lakshmanan wrote:
      > --- Klaus Bosau <kbosau@...> wrote:
      >> On Tue, 24 Jun 2003, Yegappan Lakshmanan wrote:
      >>
      >>> Hi all,
      >>>
      >>> How do I remove (not clear) a highlight group? I have defined a
      >>> highlight group like this:
      >>>
      >>> :hi link xyz Search
      >>>
      >>> How do I remove the new xyz highlight group?
      >>
      >> :hi link xyz Ignore
      >
      > This will not remove the highlight group (xyz). This command will
      > only link it to the "Ignore" highlight group.

      Yes. What's your definition of "removing" in this context? The only
      command I'm aware of to do this is ":highlight clear {group-name}"...

      >> (What do you want to achieve?)
      >
      > I want to define the highlight group "xyz" if the group is not
      > already defined:
      >
      > if !hlexists("xyz")
      > hi link xyz Search
      > endif
      >
      > In some instances, the "xyz" highlight group is defined but it
      > is not linked. In this case, I want to link it to the "Search"
      > group.

      Maybe one could use a ":highlight {group-name}" statement to find out
      whether or not it's linked...

      fun Linked(higroup)
      execute 'redir @" | silent highlight ' . a:higroup . ' | redir END'
      if @" =~ 'links to' | return 1 | endif
      return 0
      endfun

      if !hlexists("xyz") || !Linked("xyz")
      hi link xyz Search
      endif

      Is that what you wanted?

      Klaus
    • Show all 11 messages in this topic