11

This question already has an answer here:

In some occasions, Vim respond is very slow. Is there a procedure to easily identify what causes the problem?

marked as duplicate by Martin Tournoij, davidlowryduda, toro2k, CharlesL, muru Feb 4 '15 at 12:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Have you installed any plugins? – Melon Feb 4 '15 at 9:00
  • Something akin to bash -x to see what gets executed would be useful. – muru Feb 4 '15 at 9:00
  • @Melon: Yes I only have 1 plugin installed. muru: Can you explain further? – Demetris Feb 4 '15 at 9:04
  • Oh, I don't have an answer. I was just noting that something similar to bash -x would be handy. bash -x prints out every command executed, so if you have slow loading times, you could see which commands slow it down. – muru Feb 4 '15 at 9:10
  • 1
    Dangit, I answered a duplicate. While I vote to close this as a duplicate, I also respond to your comment: LatexBox shouldn't be called 2000 times after deleting 2 words. Now that you've found the problem, you have to finagle with the plugin. I wish I knew more about LatexBox to help you. – davidlowryduda Feb 4 '15 at 9:20
16

Vim has a built-in profile set of commands. See :h profile.

You would open up vim, and then run the following

:profile start profile.log

This sets up the file profile.log to be the log file. If it already exists, it will be overwritten. We now need to tell vim what to profile

:profile func *
:profile file *

This says to profile all functions and all script files. Overkill, perhaps. Now, you should do things that make vim act slowly. They are being profiled in the background. Once you have concluded, end the profiling.

:profile pause

And quit vim. Now, read the profile.log file and see what's slow. Note that this is for slow running inside of vim. If vim is slow to start up (a different problem), you should start vim with

vim --startuptime log.txt

and read the times, see what's taking so long.

  • I followed your instructions. After starting profiling, I used dw twice and then exit. Then looking at the log I got FUNCTION LatexBox_FoldLevel(), Called 1930 times – Demetris Feb 4 '15 at 9:16
  • When I try this I get "E319: Sorry, the command is not available in this version" – Barry McNamara Mar 15 at 15:31
  • @BarryMcNamara You can see more about this in :h profile. Using profile requires vim to be compiled with +profile, which happens to be true for many (but not all) vim binaries provided on distributions. You might try compiling your own vim, or installing a more featurefull binary. – davidlowryduda Mar 16 at 0:35
  • I'm using the default Mac one, and it seems that I have the normal version whereas profile is only included in the huge version. However, I managed to fix the closing lag I was experiencing by renaming my .vimrc to something else and then renaming it back. – Barry McNamara Mar 17 at 1:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.