`rg` cli options

-F, --fixed-strings Fixed String Matches
-w, --word-regexp Word Regexp
-e, --regexp search for pattern, supports multiples
-t py select only python files
-o output only matching part, not full line
--no-heading use with cut -d : -f 2 to remove filepath
-f, --file PATTERNFILE search for all patterns, one pattern per line
-s case sensitive
-i case insensitive
-S smart case
-g "**/tests/**" search only tests files with glob
-g "!**/tests/**" don’t search test files with inverse glob !
--stats number of matches, number of line matches
--sort created/modified sort results by file created/modified time
-p, --pretty rg -p foo | less, pipe color to other program

multi lines matching

Find Python Function Definitions and Usages

# this prints Definitions too because I don't know how to ignore lines
# starts with `def`
# 
# [^,] for removing imports

rg --multiline --multiline-dotall 'foo_function_name\(.*?\)[^,]' -g "!**/tests**"

search for different casing

foo_?bar searches for foo_bar, FOO_BAR, FOOBAR, fooBar

it works because

  1. _? means _ is optional, i.e. the searched words can contain 0 or 1 _
  2. The search is case insensitive by default