123022Re: Highlight group exists but no highlighting
- May 1, 2011
> syntax keyword UserKeywords Samkit CHECKME REVIEW CHECKMEYou probably don't want the 'def' in there, but it probably doesn't
> highlight def link UserKeywords Todo
> This works fine if I open an unnamed file like just "gvim".Syntax is buffer-specific, so as soon as you edit any other file of any
other type, it will no longer be in effect.
> I am suspecting that something is calling "highlight clear" but I amThat won't be happening. You can confirm this, though, by typing
> not sure of this.
It will show the highlight group (even with 'cleared' beside it, if it
has been cleared), and in the line below, the file that last set it (or
will let you know where syntax groups originated, though this is often a
little less useful (cleared groups are not shown, I don't think).
> Additionally after opening 1.c I checked if my syntax group exists andThis can't really be possible (that the syntax group exists). Probably
> it exists so it can only be the work of "highlight clear".
the highlight group for your syntax item exists, but the actual syntax
rule will not. I.e. you will see it listed in :highlight but not in
> :hi UserKeywordsThis is as expected.
> UserKeywords xxx links to Todo
If you do :syn UserKeywords, though, you will not see it.
> For this much highlighting I would not like to create a newYou can use an autocommand to just run the syntax you want on those
> runtimepath/after/syntax/default.vim containing above syntax+highlight
> group commands and then source it for every BufRead and FileRead.
events. Put something like this in .vimrc:
autocmd BufNewFile,BufRead * syntax keyword UserKeywords
\ Samkit CHECKME REVIEW CHECKME containedin=ALL
Adjust the * if you want to apply to specific filetypes, and ensure it
is after the filetype on and/or syntax on commands in your vimrc or the
autocommanes may run before those related to syntax and thus the former
may have the syntax cleared by the latter.
You probably don't need to do the highlight command similarly; just
having it in your .vimrc as you currently do is probably enough. But if
you need to include it, or a little more highlighting, in an
autocommand, a small function in your .vimrc which you call with an
autocommand becomes an attractive option.
Hope this helps, and gives enough debugging tips, too.
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
- << Previous post in topic Next post in topic >>