On 4/12/07, Kirk <[EMAIL PROTECTED]> wrote:
Is there any simple way to have custom blocks of code highlighted and the
remaining code outside the blocks not highlighted?
For example:

# file.txt
some plain text
[my-custom-tag] some custom text [/my-custom-tag]
Some more plain text
...
# end of file

So the idea would be to open VIM using file.txt and the code inside the
custom tags would be highlighted.
I've been working something very similar for highlighting code
examples in vim helpfiles.  As an example:

========= Begin Example ========
Block: MyExample
   let s:myvar = "testing"
   call myfunc("an arg")

Text that shouldn't get highlighted.
========= End Example =========

--------------- Begin Code -----------------
syn include @VimL syntax/vim.vim

syn match blocktestPrefix /^Block:/ contained nextgroup=blocktestDesc
syn match blocktestDesc /\(Block:\)\@<=.*$/ contained
syn region blocktestText
contains=blocktestPrefix,blocktestDesc,blocktestBody,@VimL
start=/^Block:.*$\n^\s\+/me=s+1 end=/^\S/me=s-1

" Highlight Linking
hi def link blocktestPrefix Todo
hi def link blocktestDesc PreProc
hi def link blocktestBody Label
hi def link blocktestComment Comment
-------------- End Code ---------------------

I found |syntax.txt| and |usr_44.txt| to be helpful.


--
Ian Tegebo

Reply via email to