为什么我不能通过本地vimrc文件更改vim语法高亮?

时间:2015-07-08 10:29:37

标签: vim syntax highlighting

我正在尝试通过将其他说明放入本地配置$project/.lvimrc来自定义vim突出显示,该配置由https://github.com/embear/vim-localvimrc插件管理。

不幸的是,它似乎像

这样的命令
syntax match Operator "\<MYOP\>"
位于.lvimrc

被vim静默忽略。在命令行中键入命令可以按预期方式工作。来自.lvimrc的其他命令也有效。那么是什么阻止vim正确解释本地突出显示呢?

2 个答案:

答案 0 :(得分:1)

这是因为https://github.com/embear/vim-localvimrc插件默认情况下会在沙箱中启动本地文件。沙箱中不允许使用语法命令(至少在我的设置中),因此引发了异常。出于某种原因,Vim默默处理这些异常。

就我而言,以下修改形成了一个解决方案:

  1. 通过将let g:localvimrc_sandbox = 0添加到master .vimrc文件
  2. 来禁用localvimrc的沙箱
  3. set conceallevel=2添加到localvimrc

答案 1 :(得分:0)

加载顺序可能有问题,即加载了.lvimrc,然后加载文件类型语法并覆盖echom语法命令。您可以通过在两个文件中包含You should not modify the syntax files supplied with Vim to add your extensions. When you install the next version of Vim, you will lose your changes. Instead you should create a file under the ~/.vim/after/syntax directory with the same name as the original syntax file and add your additions to this file. For more information, read |mysyntaxfile-add| |'runtimepath'| 语句来检查它。

另请注意,本地vimrc不是自定义语法高亮的标准方法。来自Vim FAQ 24.11

Content="{x:Static p:Resources.MainWindow}"