I was editing a LaTeX file using VIM and noticed that the scrolling is quite slow. Here is how I troubleshoot it.

The Symptom

I made a small screen cast showing what I mean by "slow". I opened the file, moved the cursor to the first line, and then pressed and held j, until the cursor reached the end of the file. You can easily notice the lag starting from around line 80.

Screencast of slow VIM scrolling.

First Attempt: Plugins

At first, one could easily blame certain plugins (especially I recently installed YouCompleteMe). I used Vundle to manage my plugins so it is relatively easy to disable them. But this ends up nowhere: even after I disabled all plugins, the problem still persists.


I found an excellent guide from VIM Wiki about how to troubleshoot VIM problems. Here are what I tried:

  1. Run VIM without any customization---OK, no scrolling issue.
$ vim -N -u NONE -i NONE main.tex
  1. Only load my .vimrc---no luck, still sluggish.
$ vim -N --noplugin -i NONE main.tex
  1. Binary searching issue inside .vimrc using the finish command, which tells VIM to stop loading further commands.

Finally, I was able to pinpoint this line inside my .vimrc:

set cursorline

Then I did a :h cursorline and found these:

Highlight the screen line of the cursor with CursorLine |hl-CursorLine|. Useful to easily spot the cursor. Will make screen redrawing slower.

I suspect because I do have several large chunks (16 by 16) of tabular environment inside the file, but it is still surprising that a modern computer can not handle such seemingly simple text editing.

I Googled online and did not found any useful solutions. I guess for now I will just have to live with it. Fortunately I do not have many such LaTeX files.