Ron Aaron wrote:
Is this possible w/ vim's syntax highlighting?
On Wednesday, December 9, 2020 at 10:56:35 AM UTC+2 Ron Aaron wrote:
Hi all -
I want to have a keyword (user-defined function) highlighted by my
syntax file.
The code looks like this:
: foo blah blah ;
In this case I want "foo" to be scooped up. What I'm doing now is
this:
syn match colonDef "^\s*:\s\+\zs\S\+"
That highlights the correct thing (e.g. 'foo') where it's defined,
but I can't figure out how to get it to be highlighted elsewhere
in the code (e.g. when simply 'foo' appears without a leading colon).
How can I accomplish this?
What do you mean by "vim's syntax highlighting"? Assuming no filetype,
say in a file called "joe.coffee", you could type
syn keyword colonDef foo
hi link colonDef Statement
and foo would be highlighted as Statement in your file.
Somehow I don't think you're really meaning "vim's syntax highlighting",
but rather "vim's syntax highlighting for the XYZ filetype". Naturally,
that missing information greatly affects things. Syntax highlighting
involves groups, containment, matches, regions, etc. My guess is that
you want your modified "colonDef" highlighting to occur in some region
defined by the filetype's syntax highlighting, but you've defined a
match that is not contained in that region. To find out what that region
is named, you could try my plugin:
http://www.drchip.org/astronaut/vim/index.html#HILINKS and use :HLT!,
move the cursor about, and you'll see a trace explaining what syntax and
highlighting regions/etc are involved. Additionally, there's issues of
priority involved, but often you can use "containedin=..." to get what
you want.
Once you've done that, you could place a file in your
.vim/after/syntax/XYZ.vim file the extra directions giving the
additional highlighting you want.
Regards,
Chip Campbell
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/01ee4915-46e8-bb5a-df6c-ee6f008de599%40drchip.org.