junegunn / fzf.vim

fzf :heart: vim
MIT License
9.51k stars 581 forks source link

Search text in files of certain type #1530

Closed lispercat closed 3 months ago

lispercat commented 3 months ago

Maybe it's a stupid question but I didn't find the answer anywhere. How do I execute "ag sometext --java" using Ag: command? When I just say ":Ag sometext --java" it concatenates --java into the text search

junegunn commented 3 months ago

See https://github.com/junegunn/fzf.vim/issues/1533#issuecomment-2015075571

Since you asked about ag, not rg, I would do something like this:

command! -complete=file -bang -nargs=* Ag
  \ call fzf#vim#grep("ag --filename --nogroup --column --color -- ".<q-args>, fzf#vim#with_preview(), <bang>0)

But it seems ag doesn't print the file name when you specify a single file even when --filename is given, so that will not work correctly.

ag --filename --nogroup --column --color -- fzf README.md