I am a happy user of VIM, except for some bits which I really want vim to improve on. One main issue is frequent slowdown of VIM spoiling the amazingly productive text-editing experience on a fastest desktop PC that one can find and a fresh linux installation. This is more with after start-up than during start-up.
Finding the causes of slowdown is a big headache: it could be .vimrc or plugins or too many syntax highlighting or number of buffers etc. None of these reasons make sense to me given a gaming PC that runs multiple graphics engines. After all, I am working with plain text not 3D graphics! At least vim must not be any slower than the basic utilities gedit or notepad!! I will proceed with these reasons anyway.
To highlight, two of the main reasons that I find for this popular slow down are:
- Syntax highlighting (this is surprising, given the fastest processors these days)
Too many redraw (refresh) operations by any means
2a. I actually assume having any number of buffers open must not cause vim to slow down. But this also has been a case where I notice a significant slow down. We deal with one buffer at a time after all!
Some specific solutions that I found so far are:
:set relativenumberand also
:set cursorlinesince they cause too many redraws. (yes it is a silly reason, given fastest processors and GPUs these days! But rest of the reasons are no less. And brace yourselves, you have too many of them.)
:set regexpengine=1According to this answer, Vim 7.4 has introduced a weaker regex engine and setting this option will revert it to older, causing a significant speed up.
:set ttyfastInstructs the vim engine to try redrawing as fewer times as possible.
:syntax off-- remove so that vim doesn't need to work on colouring keywords etc! (its indeed a radical solution, but at least will tell you how serious the syntax is and also whether it is actually the reason)
Current folding method could be a cause of the slow-down, especially if it is
expr. (i.e. change
:set foldmethod=exprto something else)
Autocommands. Disable everyone of them in your vimrc and see if it improved the speed. Having too many parallel processes like autocommands, on a single-thread machine like Vim can cause a significant slow down.
:set synmaxcol=xxxx(as per romainl's answer) with xxx a number less than the default value of 3000. e.g. 200.
You might be having too many plugins, with unknown lags. So go for a trial-and-error to find out the culprit plugin and remove it.
You might be having a number of buffers open, try removing some using
Like many older systems, ageing might be a problem, especially when dealing with multiple buffers open. Agreed on having no clue about the root cause of the problem, simply restart VIM and one often sees a significant improvement.
Try restarting vim with no plugins and vimrc using
>> vim -u NONE -U NONE -N, see if it solved the problem.
Finally, start a profiler (many ways to do this!) as mentioned in one of the answers below and break your head until you find the reason.
In a nutshell, My main question is this:
Can somebody tell me how can a willing practitioner actively avoid the most annoying vim's slowdown? (Hopefully in a user friendly non-geeky way) -- All I want is a simple, ready-to-use, fast plain-text editor!!
For the recent NeoVim alternative, I am not fully satisfied while I tried using it. I am not sure if it solves any existing problems but as I notice it does create new problems of interfacing and transition.
I know there are a number of questions on this, I paste them below. Hope this post serves as a starting point Wiki for all these problems. It is unfortunate that none of them are a single point of resource useful for this most popular problem within vim community. Hope this question becomes one!
- How do I debug my vimrc file?
- Vim slows down over time with syntax on
- Improve performance of syntax highlighting in Vim
- Vim response quite slow
- Syntax highlighting causes terrible lag in Vim
- How to see which plugins are making Vim slow?
- Vim slow with ruby syntax highlighting
- Enabling syntax and syntax folding in vim with large C file makes completion slow
- Syntax highlighting causes terrible lag in Vim
To claim some final words, it is a pity. Especially given the popularity and the number of fan-boys within the tech community, plus the number of active projects at any point of time ever since Unix. Vim, while being arguably the most useful programmable text editor on earth, lies down in an old-age single-threaded implementation with minimal configurable teletype appearance and many other rusty functionalities as I hear from techie friends. I wish to know that I am wrong with some of these understandings.
I have never contributed to Open source, but I am an enthusiastic basic programmer with love for open source. Once I learn how to, I will make sure vim will bear at least one of my contributions to ail these problems.