Monday, February 9, 2015

Re: Word boundry would not work when using some wierd Unicode chars with the 'contained' syntax

> I was not talking about fileencoding, I was talking about the :scriptencoding command, which you embed in a script to tell Vim how to read the following bytes.
>
> But I tried it, and I see the problem you describe anyway. So encoding is not the issue.
>
> I did note that putting any other text between your marker characters and your keywords lets the highlighting work as expected. E.g. this line highlights properly:
>
> ⣱ man bind | less ⡇
>
> But not this one:
>
> ⣱man bind | less⡇
>
> I think this is because of the way :syn-keyword is built to also allow multibyte
> characters. I'm not sure whether it should be considered a bug or not but it
> certainly is not expected. However I don't know of an elegant solution for it,
> other than using "match" instead of "keyword".
>
> :help :syn-define says:
> > 1. Keyword
> > It can only contain keyword characters, according to the 'iskeyword'
> > option. It cannot contain other syntax items. It will only match with a
> > complete word (there are no keyword characters before or after the match).
> > The keyword "if" would match in "if(a=b)", but not in "ifdef x", because
> > "(" is not a keyword character and "d" is.
>
> In other words, a keyword will be matched when there are not "keyword"
> characters around the match.
>
> :help E789 (within :help :syn-keyword)
> > Don't forget that a keyword can only be recognized if all the
> > characters are included in the 'iskeyword' option. If one character
> > isn't, the keyword will never be recognized.
> > Multi-byte characters can also be used. These do not have to be in
> > 'iskeyword'.
>
> But here, we find that keyword characters for the sake of :syn-keyword include
> both 'iskeyword' and also *any multibyte character*.
>
> So in your case, the special multibyte text counts as a keyword character for
> syntax purposes. Therefore the actual keywords must be separated from the
> special marker text.



I see, any multi-byte character would be treated as keyword character so that quick search for unicode strings would work as expected.

such that '字符' will be highlighted by quick search out of '<<<字符>>>'.

And there's an implicit logic that word boundry would apply where regular keywords and multi-byte keywords concatinates.

such that '字符' will also be highlighted by quick search out of 'abc字符xyz'.

But such implicit logic does not apply to syntax keywords.

I shall use "syntax match"es in replace of my "syntax keyword" definitions, and my scripts should work again.

Many thanks ~

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