how to display current syntax and highlight items

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

how to display current syntax and highlight items

Marvin Renich
I have looked through index.txt (especially g commands), syntax.txt, and
usr_06.txt, but I could not find any reference to displaying the name of
the current syntax item and/or highlight item of the character under the
cursor.  I am pretty sure that there was a tip about this on this list
in the distant past, but cannot find it.  Can anyone point me to the
correct help tag?

Thanks...Marvin

--
--
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 to display current syntax and highlight items

Magnus Woldrich
Here you go:
https://github.com/trapd00r/configs/blob/master/vim/nancy/000-functions.vim#L159

--
--
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 to display current syntax and highlight items

Dominique Pellé
In reply to this post by Marvin Renich
Marvin Renich <[hidden email]> wrote:

> I have looked through index.txt (especially g commands), syntax.txt, and
> usr_06.txt, but I could not find any reference to displaying the name of
> the current syntax item and/or highlight item of the character under the
> cursor.  I am pretty sure that there was a tip about this on this list
> in the distant past, but cannot find it.  Can anyone point me to the
> correct help tag?

In my ~/.vimrc, I have this to display the syntax group under
the cursor in the statusline:

" Function used to display syntax group.
function! SyntaxItem()
  return synIDattr(synID(line("."),col("."),1),"name")
endfunction

And my statusline has this among other things:

set statusline+=%{SyntaxItem()}

Regards
Dominique

--
--
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 to display current syntax and highlight items

Marvin Renich
In reply to this post by Magnus Woldrich
* Magnus Woldrich <[hidden email]> [190212 11:38]:
> Here you go:
> https://github.com/trapd00r/configs/blob/master/vim/nancy/000-functions.vim#L159

Thanks!  That gives the info I want, and it also gave me the clue
to find the help (synID) and the original tip that I was looking for:
Tip 99 on the old «https://www.vim.org/tips/» page, now at
«http://vim.wikia.com/wiki/Identify_the_syntax_highlighting_group_used_at_the_cursor».

I like your use of map over synstack to give all of the contained syntax
items.

...Marvin

--
--
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 to display current syntax and highlight items

Jürgen Krämer-4
In reply to this post by Marvin Renich
[accidentally sent privately, so sending it again]

Hi,

Marvin Renich schrieb am 12.02.2019 um 17:33:
> I have looked through index.txt (especially g commands), syntax.txt, and
> usr_06.txt, but I could not find any reference to displaying the name of
> the current syntax item and/or highlight item of the character under the
> cursor.  I am pretty sure that there was a tip about this on this list
> in the distant past, but cannot find it.  Can anyone point me to the
> correct help tag?

there is the HiLinkTrace plugin by Dr. Chip. You can find it on his home
page (http://www.drchip.org/astronaut/vim/index.html#HILINKS). It provides
(among others) the :HLT and :HLT! commands. I find the !-variant especially
useful; it shows and updates the highlighting trace and syntax stack on
every cursor movement.

Regards,
Jürgen

--
~
~
~
:wq

--
--
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 to display current syntax and highlight items

Paul-7
In reply to this post by Marvin Renich
On Tue, Feb 12, 2019 at 11:33:46AM -0500, Marvin Renich wrote:
>I have looked through index.txt (especially g commands), syntax.txt, and
>usr_06.txt, but I could not find any reference to displaying the name of
>the current syntax item and/or highlight item of the character under the
>cursor.  I am pretty sure that there was a tip about this on this list
>in the distant past, but cannot find it.  Can anyone point me to the
>correct help tag?

Yet another option:

command! WhatHighlight echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"

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

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: how to display current syntax and highlight items

Marvin Renich
In reply to this post by Marvin Renich
* Marvin Renich <[hidden email]> [190214 08:06]:
> Thanks!  That gives the info I want, and it also gave me the clue

Wow!  Looking at the Received: headers of the previous message, Google's
servers first accepted the message immediately on Feb 12, but it spent
two days hung up on an internal Google server, finally being delivered
yesterday!

Thanks for all the answers I got from everyone.

...Marvin

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