On Sunday, February 8, 2015 at 1:05:02 PM UTC-6, Jacky Liu wrote:
> 
> 
> 
> OK, I added a modeline to my text file to tell Vim the fileencoding 
> specifically:
> 
> /* Vim: set fileencoding=utf-8: */
> /* Vim: set tabstop=4: */
> 
>       ⣱man bind | less⡇
> 
>       +man bind | less+
> 
> the 'tabstop' option was there to make sure the modeline works. the result 
> seems to have no defference.
> 
> For your reference: The underlying fileencoding in respect of my daily usage 
> of Vim was almost always utf-8.
> 


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.

-- 
-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to