I tried today to perform a search on every files of a project. I use Ctrl-P and search on lines like so :

screenshot

But the result of the search is only on the previously opened file. Here I open only main.php.

Do you know a way to search on all files without having to open them one by one ?

Thanks,

  • 1
    This is something I want as well. If you're using ack or ag, performance shouldn't be an issue. Plus if you're using neovim, it should be async, so there shouldn't be any block either. – mhartington Jun 12 '15 at 3:42
  • Finally I use ag as ctrlp command :) – nobe4 Jun 12 '15 at 4:51
up vote 11 down vote accepted

:CtrlPLine is actually supposed to work on listed buffers.

If you absolutely want to use that feature on every file in your project, you could add them to the argument list (and thus the buffer list) with something like:

:argadd **/*.php

but that doesn't sound like a very good idea for performance reasons.

Using :vimgrep or :grep sounds a lot better to me:

:vim foo **/*.php
:cw

You lose the "fuzziness" of CtrlP, obviously, but you get reliability and flexibility in return.

Reference:

:help :argadd
:help :vimgrep
:help :grep
:help :cwindow
:help quickfix
  • A key difference between CtrlP and vim-grep, is CtrlP is interactive. – ideasman42 Feb 7 '17 at 0:00

You should use thoses plugins Sidesearch or fzf

Both allow to search in recursive directories using silversearch-ag

fzf allow to search on the listed files which include your string.

  • 1
    Hi @MisterBanal, welcome on our site! You should precise in your answer if these plugins can be interfaced with CtrlP as OP asked. If they can be interfaced you should explain how and if they can't you should at least give a basic example of how to use them otherwise your answer doesn't really answer the question. (You can change your answer with the "edit" button under the text). – statox Feb 6 '17 at 14:28

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.