Monday, May 5, 2014

Re: disable syntax highlighting for a section

Christian Brabandt wrote:
> Am 2014-05-02 23:46, schrieb shawn wilson:
>> Sometimes (especially in documentation) syntax highlighting really
>> messes up. However, I don't really want to highlight documentation
>> anyway, so can I disable it per line?
>>
>> So, basically, what I want is to be able to select a block and say,
>> don't do anything from within this block (and maybe have it set a mark
>> or something so that I can insert stuff in the middle and it won't
>> mess with new text)?
>
> No. There is really no builtin way to disable syntax linewise. It
> doesn't really
> make sense anyhow, as the syntax engine often needs to match across
> lines and
> therefore depends on it.
>
> As for your original problem, read the help at :h :syn-sync and see if
> you can
> manually resync the syntax engine, if you notice wrong behaviour. I
> assume,
> you only experience this for a specific filetype, so it might be a
> good idea to
> report those bugs to the maintainer of that specific syntax script.
> Look into the
> $VIMRUNTIME/syntax/<language>.vim script for his contact data.
>
> Nevertheless, you can trick the syntax engine to stop highlighting
> specific
> lines. This is rather hacky approach, but it should work. You would
> add some
> specific syntax matches, that link to a not-defined syntax group and
> use a pattern with the \%l line matching.
>
> E.g. to stop syntax highlighting in the lines 75-80 in the current
> buffer,
> issue: :syn match NoSyntax /\%>74l.*\%<81l/
> This should clear syntax highlighting (except for keywords). I'll
> attach a
> plugin like script, to test this out. Drawback is, it needs to
> manually update
> the regions since those ranges given in the syn-match command will be
> fixed and not
> updated when lines changed. For that reason, that script tries to
> update the
> regions on TextChanged autocommands. Not sure, how useful this is.
>
Hello, Christian:

You might want to include "containedin=ALL" in your syntax line, too.

Regards,
Chip Campbell

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: