In some occasions, Vim respond is very slow. Is there a procedure to easily identify what causes the problem?
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 gotFUNCTION 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 '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 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 '19 at 1:16
bash -x
to see what gets executed would be useful. – muru Feb 4 '15 at 9:00