In some occasions, Vim respond is very slow. Is there a procedure to easily identify what causes the problem?
Asked
Active
Viewed 1.7k times
26
1 Answers
46
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.
davidlowryduda
- 2,424
- 19
- 27
-
I followed your instructions. After starting profiling, I used
dwtwice and then exit. Then looking at the log I gotFUNCTION LatexBox_FoldLevel(), Called 1930 times– Demetris Feb 04 '15 at 09:16 -
When I try this I get "E319: Sorry, the command is not available in this version" – Barry McNamara Mar 15 '19 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 '19 at 00: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 '19 at 01:16
bash -xto see what gets executed would be useful. – muru Feb 04 '15 at 09:00bash -xwould be handy.bash -xprints out every command executed, so if you have slow loading times, you could see which commands slow it down. – muru Feb 04 '15 at 09:10