How to search for text in all files in a directory

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, add this to kakrc:

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!

Hi. There’s several options for you:

  • builtin grep command.
  • my variant of flygrep
  • fzf.kak supports interactive grepping inside file contents if skim is installed.

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

1 Like

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

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

1 Like

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.)

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