# What is the better way to search string in project?

**URL:** <https://discuss.kakoune.com/t/what-is-the-better-way-to-search-string-in-project/2374>\
**Category:** Help\
**Tags:** grep\
**Created:** [January 5, 2024, 5:47pm UTC](https://discuss.kakoune.com/t/what-is-the-better-way-to-search-string-in-project/2374 "2024-01-05T17:47:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [January 5, 2024, 5:47pm UTC](https://discuss.kakoune.com/t/what-is-the-better-way-to-search-string-in-project/2374/1 "2024-01-05T17:47:09Z")

</div>

I found the following to grep but I didn’t found a complete solution to preview and filter :

# 1) fzf.kak is public archive but always very good

I’m not sure it will be working in time but until now, it is.  
Do you know how to filter only specific file extension by using fzf-grep ?

# 2) script using fzf + ripgrep

This can be found on the site of fzf.  
But until now I didn’t found how to retrieve the result in kakoune  
because it is sent back with extra “'” surrounding charaters.  
This should be nice to be plugin independent.

> **[GitHub - junegunn/fzf: :cherry\_blossom: A command-line fuzzy finder](https://github.com/junegunn/fzf#3-interactive-ripgrep-integration)**
>
> :cherry\_blossom: A command-line fuzzy finder

https://embed.reddit.com/r/kakoune/comments/17ehebv/fzf_ripgrep_bat_without_plugin/?embed=true&ref_source=embed&ref=share

> [@The Kakoune way](https://discuss.kakoune.com/t/the-kakoune-way/2316/9):
>
> I thought I could search from ripgrep with fzf-tmux by adapting the script “frf” by replacing tmux by fzf-tmux : #!/usr/bin/env bash # 1. Search for text in files using Ripgrep # 2. Interactively narrow down the list using fzf # 3. Open the file in Vim rg --color=always --line-number --no-heading --smart-case "${\*:-}" | fzf-tmux --ansi \ --color "hl:-1:underline,hl+:-1:underline:reverse" \ --delimiter : \ --preview 'batcat --color=always {1} --highlight-line {2}' \ --…

> <https://github.com/junegunn/fzf/issues/3506>
>
> \- \[X\] I have read through the manual page (\`man fzf\`)
> \- \[X\] I have the latest… version of fzf
> \- \[X\] I have searched through the existing issues
> 
> \## Info
> 
> \- OS
> - \[X\] Linux
> - \[\] Mac OS X
> - \[\] Windows
> - \[\] Etc.
> \- Shell
> - \[X\] bash
> - \[\] zsh
> - \[\] fish
> 
> \## Problem / Steps to reproduce
> 
> I'm looking to use script with \`--bind 'enter:become(echo {1} {2})'\`  
> {1} is for path of file {2} is for line number.  
> The script is called from editor (kakoune) and the previous command of script allow to retrieve the information of fzf to be retrieved in the editor.  
> 
> It is working well with only one argument \`--bind 'enter:become(echo {1})'\`. Because with editor, it doesn't care to have the command \`:e 'path\_n\_fileName'\` rather that \`:e path\_n\_fileName\`  
> With both arguments, it is the same, I can see that the command is sending \`'path\_n\_fileName 13'\` rather that \`path\_n\_fileName 13\`. But because of that, the editor can not work with several arguments sent.  
> It is not working because of the extra character added \`'\`.  
> I tested just in the editor that it is working by hand with \`:e path\_n\_fileName 13\` and not with \`:e 'path\_n\_fileName 13'\`.  
> 
> Is there a way to do it working without the extra character added ?

# 3) grep command in kak

This is working well but there is no file preview.

For 3) it is as the quick fix list of vim but there is no preview.  
With 1) and 2), At contrary, there is the preview but when the file is selected you need to search again if you want open another file of the result list.

What is the best solution to grep with preview in kak project to work efficiently with full options to filter ?  
How do you use it ?

---

<div class="post-metadata">

**Author:** ![lauccode](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lauccode/32/52_2.png) [@lauccode](https://discuss.kakoune.com/u/lauccode)\
**Post date:** [March 6, 2024, 4:54pm UTC](https://discuss.kakoune.com/t/what-is-the-better-way-to-search-string-in-project/2374/2 "2024-03-06T16:54:44Z")

</div>

I found a solution and I explain how I do here : [How to use kak\_selection? - Help - Kakoune Community Hub](https://discuss.kakoune.com/t/how-to-use-kak-selection/2423/5)

---

<div class="post-metadata">

**Author:** ![marcc](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/marcc/32/1464_2.png) [@marcc](https://discuss.kakoune.com/u/marcc)\
**Post date:** [March 6, 2024, 5:58pm UTC](https://discuss.kakoune.com/t/what-is-the-better-way-to-search-string-in-project/2374/3 "2024-03-06T17:58:32Z")

</div>

FWIW the way I solve this is using Kakoune-daemon with tig as my file explorer (works with git projects).

Tig integrates with git grep, has a netrw-style file explorer, staging view to access changed files and much more. The grep view also has a preview window. Since Kakoune runs in daemon mode, I can exit out of kakoune, search for a file in tig, and then reenter tig with my state remaining.
