1

I'm using vim now for almost over a month and I am very dedicated to it. But since I added a few plugins, navigating through larger files (400+ lines... especially PHP files) makes vim pretty slow. It doesn't bother me much, because it is still pretty fast.

But I sometimes face the problem that navigating with hjkl hangs and even though I stopped pressing j for instance it keeps going for quite a while which is very annoying.

I run vim in iTerm on my mac and I'm not sure what to do here.

Thank you for any help.

//edit: Okay I found now what causes trouble. Everything that changes the current line style or messes with line numbers causes trouble.

So set cursorline or set rnu nu are causing my vim to lag. I think it is because the "redraw" is a pain for my terminal.

lumio
  • 7,428
  • 4
  • 40
  • 56
  • 1
    FWIW, you shouldn't be pressing any of those keys more than once. `:set rnu nu` and then use `3j` or whatever to go down/up. And `f` or `F` to go forward and backwards on some line. – Wayne Werner Dec 22 '16 at 11:39
  • how big the file is? xGib? – Kent Dec 22 '16 at 12:00
  • I just realized that it is especially slow on PHP files, cause 400 lines of code is not that large" – lumio Dec 22 '16 at 14:33
  • @WayneWerner Good idea, I'll disabled that – lumio Dec 22 '16 at 14:33
  • @WayneWerner granted, for moving left and right, Ff and 0^$ keys work most of the time, but do you seriously suggest counting how many lines down I need to go every time I need to change something a few lines lower or higher? – Mad Wombat Dec 22 '16 at 15:38
  • @Lumio if it only happens on PHP files, it is probably the fault of whatever PHP plugins you are using. A lot of language specific plugins attempt things like documentation lookups and completions. See if you can tweak these features to make things snappier. – Mad Wombat Dec 22 '16 at 15:39
  • @MadWombat hence, `:set rnu nu` - because counting is for the birds, and having 0 as the current line isn't nearly as much use as the current line number :) – Wayne Werner Dec 22 '16 at 16:22
  • @WayneWerner Ah, that is a nice setting. – Mad Wombat Dec 22 '16 at 16:34
  • @MadWombat it makes repeating macros sooo nice! – Wayne Werner Dec 22 '16 at 16:36
  • @MadWombat, I thought so too so I disabled my PHP plugin - still the same problem. Sometimes it hangs with the vimrc as well So I might need to check my vimrc and disable more options to test what causes this misbehavior – lumio Dec 22 '16 at 22:31
  • A little update ... it lags because of `set cursorline` and `set rnu nu` – lumio Dec 23 '16 at 13:19

1 Answers1

0

This is absolutely normal.

Some vim plugins are powerful, but not intended to be used handling large files (because it will require an enormous memory usage).

But the solution is simple: Use the LargeFile plugin which automatically detects when the file you are opening is too big and, in that case, disable some plugins and features just for that buffer.

bitifet
  • 3,514
  • 15
  • 37
  • I just realized, that it is slow especially on PHP files – lumio Dec 22 '16 at 14:35
  • You do have HUGUE php files? Really? …Even in that case, with LargeFile it should'nt happen, except if you have some tricky configuration which does'nt work – bitifet Dec 22 '16 at 15:39
  • …properly (sorry: I'm writting from app and cannot edit) – bitifet Dec 22 '16 at 15:39
  • Sorry, I altered my first question a bit. The file contains of just 400 lines (which to me is already a large file when it comes to something like PHP) – lumio Dec 22 '16 at 16:20
  • Ok. But 400 lines is not a "huge" file. So, of course, LargeFile won't solve your problem because it simply will not be triggered. Check first if with `:syntax off`the problem disappear (I don't think so if you use the official php syntax hilighting files) and, if not, try to comment out your whole ~/.vimrc file to, later, reenable it row by row (or block by block) until you find the code responsible of the slow down problem. – bitifet Dec 23 '16 at 07:37
  • 1
    A little update ... it lags because of `set cursorline` and `set rnu nu` – lumio Dec 23 '16 at 13:19