How does vim determine the way the text is colored in the section of ":help group-name"?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How does vim determine the way the text is colored in the section of ":help group-name"?

Peng Yu
Hi,

I see the following text in ":help group-name" colored. But when I
checked the file syntax.txt, I didn't see anything special for
indicating the colors. Could anybody let me know how vim determines
the colors? Thanks.

        *Comment        any comment

        *Constant       any constant
         String         a string constant: "this is a string"
         Character      a character constant: 'c', '\n'
         Number         a number constant: 234, 0xff
         Boolean        a boolean constant: TRUE, false
         Float          a floating point constant: 2.3e10

        *Identifier     any variable name
         Function       function name (also: methods for classes)

        *Statement      any statement
         Conditional    if, then, else, endif, switch, etc.
         Repeat         for, do, while, etc.
         Label          case, default, etc.
         Operator       "sizeof", "+", "*", etc.
         Keyword        any other keyword
         Exception      try, catch, throw

        *PreProc        generic Preprocessor
         Include        preprocessor #include
         Define         preprocessor #define
         Macro          same as Define
         PreCondit      preprocessor #if, #else, #endif, etc.

        *Type           int, long, char, etc.
         StorageClass   static, register, volatile, etc.
         Structure      struct, union, enum, etc.
         Typedef        A typedef

        *Special        any special symbol
         SpecialChar    special character in a constant
         Tag            you can use CTRL-] on this
         Delimiter      character that needs attention
         SpecialComment special things inside a comment
         Debug          debugging statements

        *Underlined     text that stands out, HTML links

        *Ignore         left blank, hidden  hl-Ignore

        *Error          any erroneous construct

        *Todo           anything that needs extra attention; mostly the
                        keywords TODO FIXME and XXX


--
Regards,
Peng

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How does vim determine the way the text is colored in the section of ":help group-name"?

Gary Johnson-4
On 2015-05-31, Peng Yu wrote:

> Hi,
>
> I see the following text in ":help group-name" colored. But when I
> checked the file syntax.txt, I didn't see anything special for
> indicating the colors. Could anybody let me know how vim determines
> the colors? Thanks.
>
>         *Comment        any comment
>
>         *Constant       any constant
[...]
>         *Todo           anything that needs extra attention; mostly the
>                         keywords TODO FIXME and XXX

The syntax highlighting of help files is controlled by the rules in
$VIMRUNTIME/syntax/help.vim.  At line 95 (of version 2014 Feb 12) is
the comment

    " Highlight group items in their own color.

followed by syn match rules with patterns that match the lines you
are asking about.

Regards,
Gary

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How does vim determine the way the text is colored in the section of ":help group-name"?

LCD 47
In reply to this post by Peng Yu
On 31 May 2015, Peng Yu <[hidden email]> wrote:
> Hi,
>
> I see the following text in ":help group-name" colored. But when
> I checked the file syntax.txt, I didn't see anything special for
> indicating the colors. Could anybody let me know how vim determines
> the colors? Thanks.
[...]

    This function (that I picked up from somebody else a few years ago)
is pretty useful for showing the exact highlighting groups in use:

nnoremap <silent> <Leader>hi :call <SID>SynStack()<CR>
function! <SID>SynStack()
    if !exists("*synstack")
        return
    endif
    echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc

    /lcd

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How does vim determine the way the text is colored in the section of ":help group-name"?

Nikolay Aleksandrovich Pavlov
2015-06-01 11:22 GMT+03:00 LCD 47 <[hidden email]>:

> On 31 May 2015, Peng Yu <[hidden email]> wrote:
>> Hi,
>>
>> I see the following text in ":help group-name" colored. But when
>> I checked the file syntax.txt, I didn't see anything special for
>> indicating the colors. Could anybody let me know how vim determines
>> the colors? Thanks.
> [...]
>
>     This function (that I picked up from somebody else a few years ago)
> is pretty useful for showing the exact highlighting groups in use:
>
> nnoremap <silent> <Leader>hi :call <SID>SynStack()<CR>
> function! <SID>SynStack()
>     if !exists("*synstack")
>         return
>     endif
>     echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
> endfunc

I define this as a command:

    command -bar ShowSyntax :echo 'Normal
'.join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'))

. Note: `Normal` at the start. Does not let you forget what is the
first layer because it is first *always*. You can have empty
synstack() output and empty `getmatches()`, but still have
non-terminal-default highlighting: this would be Normal. Also has no
visual garbage arising from list usage (`[`, `'`…`'`, `]`).

>
>     /lcd
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: How does vim determine the way the text is colored in the section of ":help group-name"?

Charles Campbell
In reply to this post by Peng Yu
Peng Yu wrote:
> Hi,
>
> I see the following text in ":help group-name" colored. But when I
> checked the file syntax.txt, I didn't see anything special for
> indicating the colors. Could anybody let me know how vim determines
> the colors? Thanks.
>
<snip>

Hello, Peng:

Syntax rules pick highlighting rules, which in turn are highlighted by
colorscheme rules.

  :help syntax
  :help colorscheme

If you'd like to see what in particular is happening in some file, you
may find

  http://www.drchip.org/astronaut/vim/index.html#HILINKS

to be of interest; in particular, try  :HLT!  with hilinks.vim.  This
command will show you the syntax stack, the highlighting trace, and the
resulting foreground/background color names as you move the cursor about.

Regards,
Chip Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.