Reputation: 7025
So after adding this to CtrlP, I know how a fast file searcher.
let g:ctrlp_user_command = 'ag %s -i --nocolor --nogroup --hidden
\ --ignore .git
\ --ignore .svn
\ --ignore .hg
\ --ignore .DS_Store
\ --ignore "**/*.pyc"
\ -g ""'
let g:ctrlp_use_caching = 0
let g:ctrlp_working_path_mode = 0
let g:ctrlp_switch_buffer = 0
let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir']
let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }
But one thing I'm trying to achieve is being able to search an entire project for any random string. The line
extension lets me search the current file, but I'd like that functionality without having to open anything.
Essentially, grep
but inside the ctrlp buffer. Is this possible or would I need to make an extension for this?
Upvotes: 2
Views: 1684
Reputation: 188
Have you looked at The-Silver-Searcher vim extension? It wouldn't be in your ctrlp, but it's kinda like grep from inside vim, and you can open the file by selecting it from the search results. To search for some string in your project you can type something like:
:Ag 'string' ./
then navigate to the file you like and push enter. You can use most of the grep options like -i
for ignore case or -v
for invert match.
Upvotes: 3