Skip to content

Instantly share code, notes, and snippets.

@davidmh
Forked from av-ast/CtrlP_acceleration
Last active July 12, 2023 16:33
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save davidmh/9011182 to your computer and use it in GitHub Desktop.
Save davidmh/9011182 to your computer and use it in GitHub Desktop.
Accelerate CtrlP by ignoring certain files and paths. Including node modules and grunt's .tmp
" Ignore some folders and files for CtrlP indexing
let g:ctrlp_custom_ignore = {
\ 'dir': '\.git$\|\.yardoc\|node_modules\|log\|tmp$',
\ 'file': '\.so$\|\.dat$|\.DS_Store$'
\ }
@jedrekdomanski
Copy link

Awesome, thanx.

@davidmh
Copy link
Author

davidmh commented Sep 21, 2019

This is super old, since then I've switched to https://github.com/junegunn/fzf.vim it's way faster than ctrlp, respects your .gitignore out of the box and it has a bunch of integrations with external search packages.

@BourgeoisBear
Copy link

FWIW, if you don't care about files outside of source control, you can use source control itself as a source-of-truth for ctrlp_user_command. This also honors .gitignore et. al. Per :help ctrlp_user_command

  " Single VCS, listing command does not list untracked files:
  let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files']
  let g:ctrlp_user_command = ['.hg', 'hg --cwd %s locate -I .']

  " Multiple VCS's:
  let g:ctrlp_user_command = {
    \ 'types': {
      \ 1: ['.git', 'cd %s && git ls-files'],
      \ 2: ['.hg', 'hg --cwd %s locate -I .'],
      \ },
    \ 'fallback': 'find %s -type f'
    \ }

  " Single VCS, listing command lists untracked files (slower):
  let g:ctrlp_user_command =
    \ ['.git', 'cd %s && git ls-files -co --exclude-standard']

  let g:ctrlp_user_command =
    \ ['.hg', 'hg --cwd %s status -numac -I . $(hg root)'] " MacOSX/Linux

  let g:ctrlp_user_command = ['.hg', 'for /f "tokens=1" %%a in (''hg root'') '
    \ . 'do hg --cwd %s status -numac -I . %%a']           " Windows

@3ximus
Copy link

3ximus commented Apr 1, 2021

@BourgeoisBear That's perfect, thanks !

@javaddev
Copy link

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment