【问题标题】:How can I cancel out a match pattern for a particular file extension?如何取消特定文件扩展名的匹配模式?
【发布时间】:2013-08-15 16:17:14
【问题描述】:

我目前在我的 vimrc 中有以下行来突出显示宽度超过 80 个字符的行。

match ErrorMsg '\%>80v.\+

我希望在编辑 SQL 文件时禁用此规则,因此我尝试根据我在帮助中阅读的内容添加此行。

 autocmd BufNew,BufRead *.sql :match ErrorMsg none

但是,每当我加载 sql 文件时,都会引发以下错误。

Error detected while processing BufRead Auto commands for "*.sql":
E488: Trailing characters: :match ErrorMsg none
Press ENTER or type command to continue

我怎样才能让它工作而不抛出错误?

【问题讨论】:

标签: vim


【解决方案1】:

摆脱高亮组。 (因为不影响结果所以去掉了冒号)

autocmd BufNew,BufRead *.sql match none

您只能使用 3 次匹配,并且您需要使用匹配、2 匹配或 3 匹配。所以你只需要清除你使用的具体那个

注意:h :match {group} 没有在 match none 的语法中列出

:mat[ch]
:mat[ch] none
                Clear a previously defined match pattern.

【讨论】:

    【解决方案2】:

    注意:在最近的 Vim 7.3+ 版本中,您可以选择使用:

    :setlocal colorcolumn=81
    

    在你其他相同的:autocmd中。

    还请注意,这和您的 :match 都是窗口本地的,因此如果您切换缓冲区,突出显示将持续存在。要完全解决这个问题(只是麻烦)需要更复杂的自动命令。

    【讨论】:

      猜你喜欢
      • 2015-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-01
      • 1970-01-01
      相关资源
      最近更新 更多