Notes about how to use ripgrep to search hidden files and configuration related to Neovim.
Search hidden files#
By default, ripgrep will ignore hidden files and directories.
To search hidden files/directories, we need to add --hidden option.
rg --hidden my_termripgrep config file#
Unlike other tools, ripgrep does not really have a default place to store its config.
Instead, you can store the config anywhere and use the env variable RIPGREP_CONFIG_PATH to point to it.
For example, you can store it in ~/.config/ripgrep/config,
then set the env variable in your .bashrc or .zshrc:
export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/configFor the content of the config, it is in facet just a list of command line options.
# show line and column number for each match
--line-number
--column
# do not print the file heading
--no-heading
--color=always
--smart-case
--max-columns=4096
# use regex by default
# --regexp
# search hidden files and directories
--hidden
# do not search .git
--glob=!.git/glob pattern in ripgrep#
Note that for globbing, the pattern foo/ and foo/** is not the same.
It seems that for negative globbing, they work similarly.
However, for positive globbing, i.e., when you only want to search in a certain directory,
they are totaly different.
rg --glob=foo/ my_termThis will find nothing, and no directory is searched.
rg --glob=foo/** my_termThis works and will find my_term if it exists in some file under foo/ directory or sub-directories.