I am using the helm-projectile setup from prelude and it has been a huge improvement to my workflow. The only remaining issue are auto-generated files (e.g. generated by CMake) which show up during helm-grep and similar operations.

Question: is there a way to exclude files in the projects folder tree from Projectile?

up vote 23 down vote accepted

Looking at projectile it seems to offer four customizations for ignoring files/directories globally. I am listing each of them below, with their documentation


A list of files globally ignored by projectile.


A list of directories globally ignored by projectile.


A list of file suffixes globally ignored by projectile.


A list of regular expressions for major modes ignored by projectile.

If a buffer is using a given major mode, projectile will ignore it for functions working with buffers.

Please note that these are global options so for example a directory in projectile-globally-ignored-directories will be ignored irrespective of the project you are working with. To ignore a file/directory for a particular project you can add a .projectile file to the project's root and add the paths to ignore prefixed with - to it like following


See the documentation of projectile-parse-dirconfig-file (or projectile's docs) for more info

Parse project ignore file and return directories to ignore and keep.

The return value will be a cons, the car being the list of directories to keep, and the cdr being the list of files or directories to ignore.

Strings starting with + will be added to the list of directories to keep, and strings starting with - will be added to the list of directories to ignore. For backward compatibility, without a prefix the string will be assumed to be an ignore string.

  • 1
    I'm unable to get projectile-globally-ignored-file-suffixes to work as (I think) it is intended. Should this contain just the suffix (i.e. "o" for object files), a file glob (i.e. "*.o") or something else? Frankly I've tried every combo I can think of and it hasn't worked. – Bklyn Nov 20 '17 at 15:17

Yes, in your .projectile file, on each line specify similar to: each line looks like:

- /path/to/somefile

Each line contains one file path.

See the official documentation on ignoring files

Another solution would be to use ag(the_silver_searcher) or rg (ripgrep) to generate project files. Here's how you can do it with rg:

(setq projectile-enable-caching t)

;;; Default rg arguments
  ;; https://github.com/BurntSushi/ripgrep
  (when (executable-find "rg")
      (defconst modi/rg-arguments
        `("--line-number"                     ; line numbers
          "--follow"                          ; follow symlinks
          "--mmap")                           ; apply memory map optimization when possible
        "Default rg arguments used in the functions in `projectile' package.")

      (defun modi/advice-projectile-use-rg ()
        "Always use `rg' for getting a list of all files in the project."
        (mapconcat 'identity
                   (append '("\\rg") ; used unaliased version of `rg': \rg
                           '("--null" ; output null separated results,
                             "--files")) ; get file names matching the regex '' (all files)
                   " "))

      (advice-add 'projectile-get-ext-command :override #'modi/advice-projectile-use-rg)))

In your project directory, specify the files you want to ignore in .gitignore and you're good to go :)

Code is from kaushalmodi's emacs config.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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