Why vim was opening markdown files slowly.

A few months back I upgraded my vim configuration to use pathogen for managing my vim plugins.

Since adding plugins was now a doddle I found a few lists of “super-duper useful vim plugins you must have” and just installed them blindly. Along the way I also configured how various plugins and the like were configured. This included a one-line change to associate .md files with markdown (by default they associate Modula-2 which I haven’t written code in for 20+ years).

And that’s when opening a markdown file started to take about three seconds.

Which is kind of insane.

For a long while I just left it alone but it bugged me today again and I mentioned it on IRC. Finn pointed me at the --startuptime flag and I gave it a shot and this is the tail of the log:

100.208  000.698  000.274: sourcing /usr/share/vim/vim74/ftplugin/html.vim
100.397  001.261  000.563: sourcing /usr/share/vim/vim74/ftplugin/markdown.vim
102.151  000.367  000.367: sourcing /usr/share/vim/vim74/syntax/javascript.vim
104.572  002.228  002.228: sourcing /usr/share/vim/vim74/syntax/vb.vim
109.634  004.917  004.917: sourcing /usr/share/vim/vim74/syntax/css.vim
1745.487  1635.791  1635.791: sourcing /home/kevin/.vim/bundle/vim-css-color/after/syntax/css.vim
1747.296  1646.199  002.896: sourcing /usr/share/vim/vim74/syntax/html.vim
1747.771  1646.809  000.610: sourcing /usr/share/vim/vim74/syntax/markdown.vim
1749.532  000.167  000.167: sourcing /usr/share/vim/vim74/ftplugin/html.vim
1749.748  000.798  000.631: sourcing /usr/share/vim/vim74/ftplugin/markdown.vim
1752.060  000.452  000.452: sourcing /usr/share/vim/vim74/syntax/javascript.vim
1755.110  002.818  002.818: sourcing /usr/share/vim/vim74/syntax/vb.vim
1766.053  010.666  010.666: sourcing /usr/share/vim/vim74/syntax/css.vim
3410.204  1645.087  1645.087: sourcing /home/kevin/.vim/bundle/vim-css-color/after/syntax/css.vim
3411.995  1662.352  003.329: sourcing /usr/share/vim/vim74/syntax/html.vim
3412.376  1662.821  000.469: sourcing /usr/share/vim/vim74/syntax/markdown.vim
3415.364  006.619: opening buffers
3415.395  000.031: BufEnter autocommands
3415.396  000.001: editing files in windows
3415.696  000.300: VimEnter autocommands
3415.697  000.001: before starting main loop
3419.461  003.764: first screen update
3419.463  000.002: --- VIM STARTED ---

Wait, what? The vim-css-color plugin is taking a combined ~3290ms? I almost never edit CSS. What does this thing bring to the table?

css_color.vim plugin by Niklas Hofer is great, but lacks two important features:

* Highlighting multiple colors on the same line (not sure if anyone uses it though)
* rgb and rgba color notation for all those fancy CSS3 niceties

So here is my patch.

Oh hell no. So I remove it (rm -rf ~/.vim/bundle/vim-css-color) and then get these startup times:

133.808  000.001: before starting main loop
137.545  003.737: first screen update
137.546  000.001: --- VIM STARTED ---

Starting up in 137.5ms is far more reasonable that 3,419.5ms. So thanks for that finn, that’s way better!