vim几乎挂起了100行typescript文件



Intellij idea 2020.1也非常慢。

  1. 从语言的角度来看,是什么让typescript比javascript的编辑器和编译器慢?他们把时间花在了什么上?
  2. 如何修复vim?
» vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Dec 10 2020 20:32:49)
macOS version
Included patches: 1-503, 505-680, 682-2292
Compiled by root@apple.com

这在Vi/Vim交换中提到过。

如果你在OSX上,似乎你需要显式地设置regexp引擎。就个人而言,我把

" ~/.vimrc
set regexpengine=0
syntax on
filetype plugin indent on

对于typescript,我有

" ~/.vim/ftplugin/typescript.vim
setlocal regexpengine=2

你可以把vim: re=2放到你的modeline中(假设你启用了set modeline),然后在Vim中打开这个文件,看看它是否挂起。

打开vim,输入:help 're'?

,可以了解更多关于regexpengine的信息。
*'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.

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

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

  • 调试Vim (profiling)
  • Vim Runtime log tl;dr:vim -V9 myVim.log yourfile.ts
  • 六世,Vim交换

打字用的语法高亮显示使它非常慢。vim上的syntax off已恢复正常。我仍然希望语法高亮显示工作,所以不是真正的答案。

brew install vim

macos的默认版本是旧的和有bug的。

最新更新