Improving Performance in Vim

Santiago Agüero
Feb 19, 2015 · 3 min read

This time I want to share with you some tips that might be handy to improve the performance in Vim. Note that for performance I mean to have a responsive & fast experience in Vim.

Avoid (slow) plugins

If you can’t, use a package manager that supports lazy loading, like vim-plug. Want a real case? Here’s one that I struggled with recently:

I like UltiSnips plugin but I frequently don’t use it. But when I need it, I really need it. So, should I remove the plugin and just rely on some custom function? Perhaps. But hey! Let’s give a try to lazy loading!

Using the tip from vim-plug wiki

There is a tip in vim-plug wiki about how to lazy load UltiSnips. But I wanted a different way as I didn’t like the fact that when you go to insert mode for the first time it will freeze by a couple of milliseconds (yes, that bothers me, a lot!.)

Using a custom function

So, I made a custom function that loads UltiSnips only when triggering expansion key.

Avoid having (thousands) plugins

If you can’t, use a package manager that supports parallel downloading, like vim-plug. If you’ve read the vim-plug documentation you might notice that you’ll need Vim with ruby support. You can inspect my dotvim wiki in order to accomplish this.

Avoid a (big) plugin for completion

Alert! This is a very personal one.

Vim’s built-in completion features, see :h ins-completion, are enough for my workflow. I did try some plugins like YouCompleteMe, Neocomplete, SuperTab, but none of those made me happy. I just needed two things:

  • Tab mapping for triggering completions and,
  • No popup if it isn’t strictly necessary (ie: I don’t want to be bother by a popup showing me that there is a single match.)

In reference to the first point the simplest way would be to have a custom function like this one but I was convinced to used the VimCompletesMe. The reason? It has just a few lines of understandable code and it makes a really Smart Tab mapping.

For the second point just use the Vim setting completeopt=menu.

Still, sometimes when I want to be precise with no ambiguities at all about what I would like to complete, I used built in mappings (eg: C-X-L for line completion). Sorry for being repetitive but :h ins-completion is your friend!

If you are using CtrlP…

…I recommend to improve the filtering speed using an external filter, like ctrlp-py-matcher. It’s super cool when you have to Fuzzy Search not only thousands of thousands of files, but also stuff like a ctag file which might be really big for huge projects!

Search faster than vimgrep

You can use plain old grep but I prefer a better solution out of the box. For that I recommend Ag as it has nice defaults that makes it faster than grep. If you’re in Windows, try Pt as it’s faster than Ag.

If you want to take advantage of Ag in Vim you can play with the grepprg and grepformat settings, for example see here.

Neat stuff for Windows

Probably this is the best thing that I’ve found (by coincidence.)

There is a tiny big thing that was slowing down the whole Vim flow (specially the startup time). The thing was that I had my Power Plan set up to be Balanced instead of High Performance. Changing to the latter did the trick. Don’t believe me? Look:

Balanced vs. High Performance Power Plan

A final tip that might change your overall experience in Windows is that you can improve the System Performance by playing with the options in %windir%\system32\SystemPropertiesPerformance.exe. I disabled all of them except for “Smooth edges of screen fonts”. Give it a try, you won’t be disappointed.

That’s all my friends!

    Santiago Agüero

    Written by

    A blog with things I’m passionate about

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade