# How to search for text in all files in a directory

**URL:** <https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785>\
**Category:** Recipes & Guides\
**Created:** [November 13, 2019, 7:15am UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785 "2019-11-13T07:15:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrworth](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lrworth/32/369_2.png) [@lrworth](https://discuss.kakoune.com/u/lrworth)\
**Post date:** [November 13, 2019, 7:15am UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/1 "2019-11-13T07:15:03Z")

</div>

Somehow I couldn’t find anyone who’d even mentioned doing this, but it’s something I used all the time in vim and sorely missed in kakoune:

**Using `rg` and `fzf` to jump to file contents!**

After installing [fzf.kak](https://github.com/andreyorst/fzf.kak), add this to kakrc:

```auto
declare-user-mode fzf
map -docstring 'all file contents' global fzf a %{: fzf -kak-cmd %{evaluate-commands} -items-cmd %{rg --column --line-number --no-heading --color=never --smart-case ''} -filter %{sed -e 's/\([^:]*\):\([^:]*\):\([^:]*\):.*/edit -existing \1 \2 \3/'}<ret>}

```

Now you can press `,fa` and chaotically type characters until you find that one thing you were looking for.

Hopefully this makes the road to kakoune smoother for someone!

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [November 13, 2019, 7:33am UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/2 "2019-11-13T07:33:02Z")

</div>

Hi. There’s several options for you:

- builtin `grep` command.
- my variant of [flygrep](https://discuss.kakoune.com/t/flygrep-like-grepping-in-kakoune/662)
- fzf.kak supports interactive grepping inside file contents if [skim](https://github.com/lotabout/skim) is installed.

As for your fzf command, I’ve found it clever and added it to the plugin:

[https://github.com/andreyorst/fzf.kak/blob/master/rc/modules/fzf-grep.kak](https://github.com/andreyorst/fzf.kak/blob/master/rc/modules/fzf-grep.kak)

---

<div class="post-metadata">

**Author:** ![lrworth](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/lrworth/32/369_2.png) [@lrworth](https://discuss.kakoune.com/u/lrworth)\
**Post date:** [November 13, 2019, 12:21pm UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/4 "2019-11-13T12:21:30Z")

</div>

I am astonished! Thank you so much for doing that!

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [November 13, 2019, 12:33pm UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/5 "2019-11-13T12:33:29Z")

</div>

please test it. By default it uses `grep` so you’ll have to change `fzf_grep_option` to `rg` in order to use ripgrep

---

<div class="post-metadata">

**Author:** ![gspia](https://discuss.kakoune.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gspia](https://discuss.kakoune.com/u/gspia)\
**Post date:** [November 17, 2019, 10:44am UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/6 "2019-11-17T10:44:00Z")

</div>

Thanks, this is really amazing with `bat`! I started to use now the defer-example at the `plug.kak` that is about fzf.kak. (Small thing, the example has `fzf_hihglight_cmd` while I had to use `fzf_highlight_command`. I also added `set-option global fzf_grep_command rg` in there.)

---

<div class="post-metadata">

**Author:** ![andreyorst](https://discuss.kakoune.com/user_avatar/discuss.kakoune.com/andreyorst/32/29_2.png) [@andreyorst](https://discuss.kakoune.com/u/andreyorst)\
**Post date:** [November 17, 2019, 4:00pm UTC](https://discuss.kakoune.com/t/how-to-search-for-text-in-all-files-in-a-directory/785/7 "2019-11-17T16:00:40Z")

</div>

oh, sorry for that. I forgot to update plug.kak readme section after renaming options in fzf.kak. Should be fixed now
