vim 几乎因 100 行打字稿文件而挂起

Pno*_*tNP 2 vim typescript

Intellij idea 2020.1 也非常慢。

\n
    \n
  1. 从语言的角度来看,与编辑器和编译器等类似的 JavaScript 相比,是什么让 TypeScript 如此缓慢?他们把时间花在什么事情上?
  2. \n
  3. 我该如何修复 vim?
  4. \n
\n
\xc2\xbb vim --version\nVIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 10 2020 20:32:49)\nmacOS version\nIncluded patches: 1-503, 505-680, 682-2292\nCompiled by root@apple.com\n
Run Code Online (Sandbox Code Playgroud)\n

lwi*_*zek 6

这在 Vi/Vim 交流中提到

如果您使用的是 OSX,那么您似乎需要在某处显式设置正则表达式引擎。就我个人而言,我把

" ~/.vimrc
set regexpengine=0
syntax on
filetype plugin indent on
Run Code Online (Sandbox Code Playgroud)

然后专门针对打字稿我有

" ~/.vim/ftplugin/typescript.vim
setlocal regexpengine=2
Run Code Online (Sandbox Code Playgroud)

vim: re=2您可以通过放入模型行(前提是启用了此功能)来亲自测试它set modeline,然后在 Vim 中打开文件以查看它是否挂起。

regexpengine如果你打开 vim 并输入,你可以了解更多信息:help 're'?

                        *'regexpengine'* *'re'*
'regexpengine' 're' number  (default 0)
            global
    This selects the default regexp engine. |two-engines|
    The possible values are:
        0   automatic selection
        1   old engine
        2   NFA engine
    Note that when using the NFA engine and the pattern contains something
    that is not supported the pattern will not match.  This is only useful
    for debugging the regexp engine.
    Using automatic selection enables Vim to switch the engine, if the
    default engine becomes too costly.  E.g., when the NFA engine uses too
    many states.  This should prevent Vim from hanging on a combination of
    a complex pattern with long text.
Run Code Online (Sandbox Code Playgroud)

抱歉,我没有完全理解为什么显式调用引擎会阻止 Vi/Vim 在 OSX 上挂起,但它对我有用,而且我已经在堆栈交换论坛上看到了它的发布。如果您完全理解原因或是否提供了其他永久修复,请发表评论。

一些有用的问题解决链接: