On Sat, 24 Feb 2007 19:31:23 +0100 "A.J.Mechelynck" <[EMAIL PROTECTED]> wrote:
> 2) The name of the "comment" syntax group is different for each > language. For instance, it may be vimComment, cComment, htmlComment, > cssComment, etc., depending on what kind of file you're editing. (The > corresponding _highlight_ groups are all linked to Comment by > default, but that can be changed, and IIUC it only applies after all > _syntax_ groups have been determined, so I guess you need to use the > correct syntax group name). Ah, OK. I didn't realize this. > 3) Taking point 2 into account, I guess the right place for your > command is in an after-syntax-script; for instance for vimscript: > > --- start ~/.vim/after/syntax/vim.vim > syn keyword Todo containedin=vimComment contained WARNING NOTE > --- end This works, but then I have to do it for each file type, which is what I was trying to avoid. > For a more ambitious solution (untested) > > autocmd Syntax * syn keyword Todo containedin=<amatch>Comment > \ contained WARNING NOTE > > The above may have to be defined late in your vimrc. When I tried this, I got E15: invalid expression <amatch>. No worries, though, because I figured it out. The trick is to use a pattern to match the containedin parameter so that it works for all comment syntax specifications -- vimComment, javaComment, whatever. The pattern is expanded whenever the syntax command gets executed, so it needs to be in an autocmd to apply to newly-registered syntaxes. :autocmd Syntax * syntax keyword myTodo \ containedin=.*Comment contained WARNING NOTE Rather than using the Todo group (which works) I put it into myTodo instead, then linked that to Todo. > Best regards, > Tony. Thanks for the clarification. I was almost pining for Emacs Lisp macros there for a second, but Vim came through (as usual). :) -- Taylor Venable [EMAIL PROTECTED] http://www.metasyntax.net/ "Simplicity is prerequisite for reliability." -- Edsger Dijkstra