【问题标题】:Vim syntax file: Adding certain characters to iskeyword isn't workingVim 语法文件:向 iskeyword 添加某些字符不起作用
【发布时间】:2011-05-12 00:39:32
【问题描述】:

我正在制作一个 Vim 语法文件,我需要在 iskeyword 选项中添加一些字符。我很难从 Vim 帮助文件中弄清楚它是如何工作的,但这是我目前写的:

set iskeyword+=_,.,-,64,133,!,?,@,172,8743,8744,8853,8592,8593,8594,8595,8596

#64 和#133 是at 符号和省略号。最后几个字符是¬、∧、∨、⊕、→、←、↓、↑和↔。

在所有这些字符中,似乎只有 _、.、- 和 ¬ (#172) 被识别为关键字字符。

我还有什么需要做的吗?还是 Vim 根本不支持超过 Unicode 中某个点的关键字字符(但 at 符号也不被识别,而且肯定在 ASCII 范围内)?

感谢您的帮助!

【问题讨论】:

    标签: vim unicode


    【解决方案1】:

    iskeyword 的帮助指向isfname 的帮助,它回答了你所有的问题:

    […]
    Multi-byte characters 256 and above are always included, only the
    characters up to 255 are specified with this option.
    For UTF-8 the characters 0xa0 to 0xff are included as well.
    […]
    The format of this option is a list of parts, separated with commas.
    Each part can be a single character number or a range.  A range is two
    character numbers with '-' in between.  A character number can be a
    decimal number between 0 and 255 or the ASCII character itself (does
    not work for digits).  Example:
    […]
    If the character is '@', all characters where isalpha() returns TRUE
    are included.  Normally these are the characters a to z and A to Z,
    plus accented characters.  To include '@' itself use "@-@".  Examples:
        "@,^a-z"    All alphabetic characters, excluding lower
                case ASCII letters.
        "a-z,A-Z,@-@"   All letters plus the '@' character.
    […]
    
    1. “此选项仅指定最多 255 个字符。”
    2. “字符数可以是 0 到 255 之间的十进制数”
    3. “要包含 '@' 本身,请使用“@-@””

    iskeyword 中包含多字节字符已经在许多列表中讨论过,例如this one

    【讨论】:

    • 这能回答吗? “总是包含 256 及以上的多字节字符”如果是这种情况,那么为什么有人会要求添加“∧、∨、⊕、→、←、↓、↑ 和 ↔”?这是vim中的错误吗?
    • @Cogwheel 不是错误,而是用法。它们始终包含在文件名识别中。这里的第一段来自'isfname'iskeyword 使用与前者相同的格式,这就是帮助重定向到那里的原因。但是请注意,此处的第二段指出“字符可以是 0 到 255 之间的十进制数”。最初的问题不是这种情况。数字高于 255,因此无法识别。没有正式的方法来处理这个问题。我的答案中链接的邮件列表包含更多信息。我希望这会有所帮助!
    猜你喜欢
    • 1970-01-01
    • 2018-08-30
    • 1970-01-01
    • 2013-04-17
    • 2012-11-18
    • 2017-12-02
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多