I have a customized grep-find-command.

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
("find . -type f -exec grep  -nHi  \"{}\" \";\"" . 31))))

How can I configure projectile to use this find & grep command? Because the default one won't work on MS Windows.

1 Answer 1


It is possible to set Projectile to use Git's version of the grep command. If you have Git installed on Windows, simply applying the configuration below should suffice:

(setq projectile-use-git-grep t)

Another alternative would be to try to use Windows' findstr command instead. One instance of a search that barely works is:

(defun grep-projectile-windows(&optional search-string)
  (let ((search-string (or search-string (read-string "[search in project] string pattern: "))))
    (shell-command-to-string (concat "findstr /s /i /p"
                           (concat "/c:\"" search-string "\" ")
                           (concat "\"" (replace-regexp-in-string "/" "\\" (projectile-project-root) t t) "*.*\"")))))

However, to have a fully working solution with this alternative, integration with Projectile would still be required by hacking into the package code, alongside better implementation of the command call (e.g., excluding undesided dirs such as .git, etc.).

A third alternative is to use other search tools search as ag or ack, that have integration with Projectile via external packages.

  • Nice! So by setting projectile-use-git-grep t and then editing vc-git-grep-template you can have additional args, like including more context in the output.
    – Hi-Angel
    Sep 21, 2023 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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