I've read it in some places that neovim is faster than vim, but many of these are a few year old blog posts and I haven't seen any actual comparisons (I'm not even sure how one could be reliable done though). Can somebody give me a rundown of what there is to know about this?
1 Answer
For most built-in operations, the runtime between Vim and NeoVim is not noticeably different. That is, both are fast enough to not care about any difference.
I've seen one situation that NeoVim is much better. If you have a big file and want to delete all lines matching a pattern, then you can do:
:g/pattern/d
In Vim, each matched line is deleted and saved to the default register. When repeating this many many times, it becomes significantly slow. The Vim workaround for faster performance is to delete to the the black hole register, _
.
:g/pattern/d _
In NeoVim, this works fast even without specifying the black hole register. If you're going to save and re-save and re-save over and over again to the default register during a :g
command, then you can speed it up by skipping all but the last one. That's probably what NeoVim is doing.
VimScript vs LuaJIT is the biggest speed difference though. NeoVim has a built-in LuaJIT compiler. Any existing plugin written in Vimscript will not necessarily run faster in NeoVim, but the plugin could be re-written in Lua (or even the faster Vimscript in Vim9) for faster performance.
time vim +q
andtime nvim +q
and also both with specifying-u NONE
, banilla neovim has 25 ms startup and vanilla vim has 42 ms pretty reliably, while loading all my plugins takes 250 - 350 ms, but the deviance is pretty great so I'd say they are rather similar for startup. For usage, we'll see :)