Vim response quite slow

11,577

Solution 1

You can use the --startuptime option when start vim:

--startuptime {fname}                   *--startuptime*
        During startup write timing messages to the file {fname}.
        This can be used to find out where time is spent while loading
        your .vimrc, plugins and opening the first file.
        When {fname} already exists new messages are appended.
        (Only available when compiled with the |+startuptime|
        feature).

Take following steps to diagnose the problem:

  • type vim --startuptime log.txt main.java in bash to start vim
  • type :tabe log.txt in vim to view the log.

Solution 2

The reason for slowness is often the not set or wrong set ruby_path on compile time of vim (see also discussion on google vim/ruby google group). It is easier to set it in vimrc, because you can change it without recompiling vim. You can set the path through the g:ruby_path variable in your .vimrc file. Don't copy and paste both, use the right one.

If you setup RBENV you have to use this one:

" ruby path if you are using rbenv
let g:ruby_path = system('echo $HOME/.rbenv/shims')

If you setup RVM you have to use this one:

" ruby path if you are using RVM
let g:ruby_path = system('rvm current')

You can also use the vim-rbenv plugin, which sets the path too.

For me the part on loading ruby specific functions in vim got 10 times faster.

If you are using jruby, than the start up slowliness can be even bigger. See examples for fixing it here.

Solution 3

If running vim 7.4,

put this in your .vimrc

set regexpengine=1

vim 7.4 has a new regex engine that appear not to work well in some situations. Previous version vim 7.3 used the old engine ( set regexpengine=1 ).

The "slow response" from syntax highlighting problem affects the vim help files as well ( and .vimrc file too ).

Solution 4

Something like this is usually caused by syntax colouring. Try with :syntax off.

Share:
11,577
Frank Cheng
Author by

Frank Cheng

Updated on August 12, 2022

Comments

  • Frank Cheng
    Frank Cheng over 1 year

    If I open a file containing 5,000 lines of code and continue to input, I found that my vim became very slow, it displays my input after about 1s.

    It even won't become any better after I start up with --noplugin. But after switching my .vimrc file, everything gets fine again. The .vimrc file is written by myself and after checking for some time, I still can't locate the error. I have clear all the key maps, but the problem still exists.

    So can you give my any advise or tell my how to debug in vim? I found there is a debug option but can't get how to work.

  • darjab
    darjab about 12 years
    It shouldn't present any problem on files that size (~5000lines), mine are significantly bigger and still no slowdown. If it was 500000 lines, maybe ...
  • Frank Cheng
    Frank Cheng about 12 years
    It's not syntax problem.I have changed to other's vimrc and the syntax is on. It works fine.thanks.
  • Frank Cheng
    Frank Cheng about 12 years
    Hi kav. My vim isn't slow on startup.
  • Frank Cheng
    Frank Cheng about 12 years
    oK, I will try it. Thank you kev.
  • Frank Cheng
    Frank Cheng about 12 years
    When i turned syntax off, the problem solved. But it will also speed up when i change vimrc file. I have refer to the same syntax in these two vimrc files.
  • Carlos Agarie
    Carlos Agarie almost 11 years
    Indeed, forcing a ruby path through this method improves vim's startup speed substantially. Thank you!
  • Bob Kocisko
    Bob Kocisko almost 8 years
    This was the answer for me with syntax coloring YAML files. Thanks!
  • Loves Probability
    Loves Probability over 7 years
    :set regexpengine=1 -- This is a great find that no other expert mentioned. I got some improvement (but not full) after this change. One other reason for my slow down was :set relativenumber which is causing a lot of screen redraws effectively showing a slowdown.