vimtricks.wiki Concise Vim tricks, one at a time.

How do I find out which scripts or plugins are slowing down my Vim startup?

Answer

:profile

Explanation

When Vim feels sluggish to start, the built-in :profile command lets you measure exactly how much time each script, function, or plugin takes to load. Instead of guessing which plugin to remove, you get precise timing data to identify the real bottleneck.

How it works

  • :profile start {file} — begin profiling and write results to {file} when done
  • :profile func * — profile all function calls
  • :profile file * — profile all sourced scripts
  • After performing the operations you want to measure, quit Vim and examine the output file

For startup profiling specifically, launch Vim from the command line with:

vim --startuptime startup.log

This logs the time taken by each script during startup. For deeper function-level profiling, add this to the top of your vimrc:

:profile start profile.log
:profile func *
:profile file *

Example

Profile all functions and scripts, then check the output:

$ vim --startuptime startup.log
$ sort -t: -k 2 -n -r startup.log | head -20

The log shows entries like:

050.320  025.130  025.130: sourcing ~/.vim/plugged/heavy-plugin/plugin/main.vim
030.100  010.050  010.050: sourcing ~/.vim/plugged/light-plugin/plugin/init.vim
005.200  002.100  002.100: sourcing $VIMRUNTIME/filetype.vim

The first column is elapsed time, the second is the time for that item — sort by it to find the slowest scripts.

Tips

  • Use :profile pause and :profile continue to measure specific sections of your workflow, not just startup
  • Neovim users can also use nvim --startuptime which works identically
  • After identifying slow plugins, consider lazy-loading them with a plugin manager that supports deferred loading

Next

How do I use PCRE-style regex in Vim without escaping every special character?