Sometimes I mis-spell the name of a file. So let's say I have a file called ThisIsAFileName and I start typing ThisS... The moment I misspell the filename (and there are no hits whatsoever), CTRL-P becomes incredibly slow. It displays each next letter at a speed of about 1 character every 5 seconds. So if I accidentally type 6 extra characters I am waiting half a minute for CTRL-P to finish displaying these characters before I can undo this.

Is this something that happens regularly? Any idea how to fix this?

  • I'm facing same issue... – Ejaz Aug 31 '17 at 18:50
  • I'm still stuck in the same situation. I try not to mis-spell, which is my current "fix", but if there's a better fix out there, I'm all ears. – user32421 Sep 1 '17 at 10:03
  • 2
    I found this article by Doug very useful. It has a section on CtrlP. Quoting from the article > However, we can tell CtrlP to run an external command to find matching > files. Now that we have ag installed, we can use it with CtrlP to make > CtrlP wicked fast. Although I haven't tried using ag myself, it seems to be something worth trying. – RIQ Oct 10 '17 at 11:33
  • Ctrl P is old, let try fzf, the performance is significantly faster. – Finn Dec 6 '18 at 11:12
  • I'm using it with ag on windows (which is considerable slower than Linux on file discovery and listing) with good results. It's not immediate, but good enough for seamlessly finding files. – Spidey Feb 23 '19 at 23:22

You can enable caching, if it is not enabled already:

let g:ctrlp_use_caching = 1

It significantly reduces lag and is ideal if there aren't a lot of changes inside the directory, ie not a lot of new or deleted files. However, as files are added or removed or renamed, the file index will become stale, and it needs to be refreshed (ie re-indexed) by pressing ctrl+p and then F5 (or alternatively, enter :CtrlPClearCache in command mode).

I prefer to use faster file search external app, and not have to deal with caching at all. I recommend either Ag (The Silver Searcher) or ripgrep. They are significantly faster than the ctrl-p's built-in search engine, and switching the engine is very easy.

Ag or Ripgrep needs to be installed first. And then in .vimrc, I add the following.

If using ripgrep:

if executable('rg')
    let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
    let g:ctrlp_use_caching = 0

If using ag:

if executable('ag')
  let g:ctrlp_user_command = 'ag -l --nocolor -g "" %s'
  let g:ctrlp_use_caching = 0
  • On Windows, Ag seems to be slower and I recommend Ripgrep instead of Ag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.