Vim 在复杂字符串后插入换行符时出现巨大延迟

Vim huge delay when inserting newline after complex strings

Vim 在特定代码块的末尾插入换行符(正常模式下的 o 或插入模式下的 return 键)需要很长时间才能插入这可以被认为是复杂的。

我将如何确定原因并解决问题?

具体案例信息:

我的情况是,有问题的 Python 代码块如下,其中包含双引号字符串中的多个单引号:

  for item in tree.xpath("//li"):
    a = item.xpath(".//div[contains(concat(' ', normalize-space(@class), ' '), ' alpha ')]/text()")[0]
    b = item.xpath(".//div[contains(concat(' ', normalize-space(@class), ' '), ' betahaus ')]/text()")[0]
    c = item.xpath(".//div[contains(concat(' ', normalize-space(@class), ' '), ' capitalism ')]/text()")[0]
    d =    item.xpath(".//div[contains(concat(' ', normalize-space(@class), ' '), ' doughnuts-of-the-realm ')]/a")[0].attrib['href']
    g = item.xpath(".//span[contains(concat(' ', normalize-space(@type), ' '), ' dontcare ')]/text()")[0]
    h = item.xpath(".//span[contains(concat(' ', normalize-space(@type), ' '), ' foo ')]/text()")

延迟不到一秒但很明显。

这台机器是 AMD Phenom(tm) 9550 2.2GHz,64 位四核处理器,这是在 Arch Linux 上,移动了 .vimrc(所以 Arch 的 vim使用默认值)。 vim 和 gvim 都受到影响。

如果我复制粘贴定义变量的行 5 次,导致大约 48 行,延迟是 3 秒。增加到超过 400 行会导致相同的延迟,这让我假设已经达到超时。

显示该问题的视频:https://youtu.be/rCSfSASrZjQ

可能与语法高亮有关;检查 :syntax off.

后延迟是否消失

如果您的 Vim 版本(具有 "huge" 功能的最新版本)支持 :syntime 命令,您可以深入研究; cp。 :help :syntime.

这可能会导致速度缓慢;然后你会联系语法插件作者(他的地址 / link 发布跟踪器你会在脚本的 header 中找到:$VIMRUNTIME/syntax/python.vim.