Search code examples
vimline

Vim: insert mode is very slow with 400+ lines


I have a file with 400+ lines (it's a thesis). When I edit it somewhere near the top (say, on line 20), Vim is snappy as always. However, editing it near the bottom (around line 400) causes a noticeable delay between me typing the character and Vim showing it on the screen. As a consequence, it is almost impossible to edit a file this big.

What is the reason for this and what can I do?

I've tried toggling the swapfile, syntax, scrolloff etc, but it doesn't seem to help. The maximum number of lines for Vim should be 2147483647, so I should actually have a long way to go here :)

In case this is related to setting maxmem, then what would be a reasonable value, considering that I edit files up to 2500 lines?

Thanks very much for any help! Cheers.


Solution

  • I recently came across this exact problem - lag while typing at the bottom of a relatively short (markdown) file. After uninstalling plugins and commenting out most of the settings in my .vimrc, I discovered that the issue was markdown folding coming from the vim-markdown plugin that is pre-installed with vim. Commenting out let g:markdown_folding = 1 did the trick.

    I still wanted to have automatic folding on markdown files, so I installed vim-markdown-folding and there are no issues with performance.