50

Vim is acting slow when I scroll. The cursor skips some lines when I'm pressing j/k continually.

I'm using xterm and urxvt. In both vim acts like this.

This happens locally, with small or big files. I do use Control + F/B they work just fine.

EDIT: ttyfast in small files did the trick but in bigger is the same. When running without customization it goes allright.

JoErNanO
  • 2,458
  • 1
  • 25
  • 27
LuRsT
  • 3,973
  • 9
  • 39
  • 51

10 Answers10

85

:set lazyredraw will buffer screen updates instead of updating all the time. I generally enable it when I'm doing a complex macro playback. Might help you here.

Cristian Ciupitu
  • 20,270
  • 7
  • 50
  • 76
Cyber Oliveira
  • 8,178
  • 4
  • 28
  • 18
47

Have you tried the 'ttyfast' option? See:

:help 'ttyfast'

for help, and:

:set ttyfast

to enable it.

Also, what version are you using? And have you tried this with no customizations to see if something you've set is interfering?

Run it like this to omit any of your vimrc settings and plugins:

vim -u NONE

EDIT: If removal of customizations fixes it. Remove things iteratively until the behavior returns. Start by narrowing it down to either a vimrc problem or to plugins.

Jeremy Cantrell
  • 26,392
  • 13
  • 55
  • 78
  • "if has("autocmd") " autocmd FileType python set complete+=k/home/lurst/.vim/pydiction-0.5/pydiction isk+=.,( "endif " has("autocmd" I commented this lines and it worked :D thanks – LuRsT Dec 05 '08 at 23:37
  • 2
    To find out what specifically is causing problems ... it may be useful to profile vim: http://stackoverflow.com/a/12216578/670654 – Rocketman Sep 20 '13 at 22:56
  • FAO NeoVim users: [the `ttyfast` option has been removed](https://neovim.io/doc/user/vim_diff.html) (see `6. Removed features`). – meshy Apr 04 '16 at 11:28
  • I was getting extremely slow/sluggish navigation (j, k, ...) on text pasted into Vim from the system clipboard. Placing "set ttyfast" in my ~/.vimrc instantly solved this problem. – Victoria Stuart Jan 20 '17 at 17:53
20

I had this problem only when using the pylint.vim plugin with syntastic. The only thing I can find that's helpful (other than disabling the syntax checker) is to disable highlighting current line:

:set cul!

This sped up my scrolling significantly.

Stephen Wood
  • 1,257
  • 1
  • 12
  • 13
  • 2
    This is great. NOTE: It only removes the *line* highlighting, it still highlights syntax. Perfect. – fredrivett Mar 06 '18 at 16:28
  • You can also do this for specific file types you know have complex syntax highlighting, e.g. `autocmd Filetype ruby setlocal cul!` – Matthew May 14 '18 at 17:42
12

Regexp Recomputation Bug on Vim

Depending on the version of Vim you are using, you might be affected by a regexp recomputation bug, whose main culprits seem to be highlighting the cursor line and displaying relative line numbers:

set relativenumber
set cursorline

The web is scattered with threads reporting this issue (here, here and here). The issue seems to be exacerbated if one also uses syntax highlighting.

Personally I just solved my slow scrolling problems by disabling relativenumber by adding this to my vimrc:

set number

My Vim

My Vim is the one provided by the vim-nox package version 2:7.3.547-7 on Debian 7.9. Typing :version in Vim yields:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 11 2014 03:17:52)

Included patches: 1-488

Community
  • 1
  • 1
JoErNanO
  • 2,458
  • 1
  • 25
  • 27
  • I never used relative number (I'm using the past since this is a very old post). I remember the syntax being the problem, but not the relative number – LuRsT Jan 01 '16 at 18:35
  • 1
    `cursorline` and `syntax` with files using complex highlighting rules (like ruby) compound pretty poorly for me. In my .vimrc I cancel out only for those files: `autocmd Filetype ruby setlocal nocursorline` – Matthew May 14 '18 at 17:35
  • This was causing my scrolling lag! Thanks a lot! – zarathustra Aug 01 '19 at 07:33
4

If the other suggestions don't work, it may be a problem with your terminal. My gnome-terminal on Ubuntu was scrolling much slower than PuTTY with the same file.

If you're using Ubuntu's default gnome-terminal, you might want try another terminal program. urxvt both worked for me (terminator had similar problems):

$ sudo apt-get install rxvt-unicode
$ urxvt

The major downside is that it doesn't look very good. You can try the advice here to make it look a bit better

References:

Edit: It seems that the real solution for me may be to stop full-screening my terminal when using vim.

Community
  • 1
  • 1
jtpereyda
  • 6,987
  • 10
  • 51
  • 80
  • 1
    Nice reviving :D. Actually after some years I found out that vim is slow with html files, maybe it's an issue with the syntax file or just because usually html files have long lines, I don't know. It's funny that you recommend rxvt since I've been using it for some time now, and I like it but hasn't fixed the vim issue. – LuRsT Apr 16 '13 at 10:17
  • Can confirm that Terminator can indeed be very slow when using Vim. I can notice a big difference between Terminator and Konsole, though both use a hefty amount of cpu time when scrolling... – timss Sep 13 '13 at 00:27
  • Not looking good isn't a drawback, because it is just a few lines in the config file away to make it one of the best looking terminals ever. – Kevin Aug 28 '15 at 07:12
3

Late answer, but the above did not help me.

First, figure out what the exact problem is rather than flailing about disabling random stuff. Vim has a super nifty profiler.

:help prof

will get you started, but I did

:prof start ~/vim_profile
:prof func *
:prof file *

Then did a bunch of super slow scrolling. Afterwards,

:prof exit

You can then look at the vim_profile and see exactly what the problem is. In my case it was the matchparen which I fixed by adding

set noshowmatch

to .vimrc, but could be different for you.

As an aside, after I got vim itself tuned, I was able to improve performance more by using a different terminal (iTerm2, or Alacritty) instead of the built in one.

jpgeek
  • 4,991
  • 2
  • 28
  • 26
2

My scrolling was fixed after disabling parenthesis highlighting. In ~/.vimrc put:

let loaded_matchparen = 1
Matthew Mitchell
  • 5,293
  • 14
  • 70
  • 122
1

Check your silent mappings as well. If you have mappings starting with j, k, h,l then that may also cause a momentary lag.

craft
  • 2,017
  • 1
  • 21
  • 30
0

I was running vim on a Raspberry Pi 1. Disabling this one line sped things up for me:

set foldmethod=syntax  "slow!
Chaim Leib Halbert
  • 2,194
  • 20
  • 23
0

I came here with similar scrolling problems. I really didn't want to turn off syntax highlighting altogether, so I disabled "set cursorcolumn" and "set cursorline" and my scrolling became much faster.