Ron Aaron wrote:
I explained exactly what I mean in the original post.

Yes, of course I'm talking about a specific file type, but the specific type is unimportant since it's something I'm creating and not something in the vim syntax files.

What I intend is simply that if the user types in (the file being created) something like:

    : foo bar ;

Then "foo" becomes a syntax keyword. The criteria for becoming a keyword in this context is that it is preceded by a colon, and delimited by white-space. Thus 'bar' is not a keyword, nor is ": foo".  Think of the leading colon-space as a function declarator.

What I can't figure out is how to trap "foo" without trapping the leading colon-space.
OK, as I said in my earlier reply, what you need is to have

 syn keyword colonDef foo

(or whatever you want foo to be highlighted as). The trick is to get the : to trigger getting that new syntax statement. You can try something like:
inoremap ; ;<esc>:call InsertNewSyntax()<cr>a

fun! InsertNewSyntax()
  if getline(".") =~ '^\s*:\s*\h\w*'
   let newsyn= substitute(getline("."),'^\s*:\s*\(\h\w*\)\s*;','\1','')
   exe "syn keyword Statement ".newsyn
  endif
endfunction
You could even make this part of your syntax file, even though it isn't strictly syntax.  Every time you type a semicolon, the function is called which checks to see if it can extract a word from  : word ; and, if it can, it will install that word as a new keyword.

Regards,
Chip Campbell


P.S. IMHO -- this topic would've better have to have been in vim_...@googlegroups.com, as it isn't associated with developing vim.

--
--
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/5028cde4-248a-c91b-21f4-fa7b4492cf52%40drchip.org.

Raspunde prin e-mail lui