Hi! pcre2grep(1) is mostly similar to `grep -P`, except that it has a -M flag for multi-line searches. It'd be nice to see such a flag in git-grep(1). Use case: grepc(1) allows one to search for C code. A couple of examples in the Linux kernel repository: $ grepc ARRAY_END include/ include/linux/array_size.h:#define ARRAY_END(arr) (&(arr)[ARRAY_SIZE(arr)]) $ grepc -tfld open fs/ fs/open.c:SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) { if (force_o_largefile()) flags |= O_LARGEFILE; return do_sys_open(AT_FDCWD, filename, flags, mode); } fs/open.c:COMPAT_SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode) { return do_sys_open(AT_FDCWD, filename, flags, mode); } grepc(1) uses a helper program to produce the regexes: grepc_c(1). Here are the regexes used internally for the above: $ grepc_c ARRAY_END (?s)^(?:[\w[](?:[\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(?:enum)\b[\w \t[\]:]*(?[ \t]*){(?:(?!^\k?}).)*^[ \t]*ARRAY_END\b\s*[=,].*?^\k}[^;]*; (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?ARRAY_END\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))(?:[\w\s\(,\)[\]]|::)*; (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?ARRAY_END\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))[ \t]*\n*(?[ \t]*){.*?^\k} (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?(?:compat_)?sys_ARRAY_END\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))(?:[\w\s\(,\)[\]]|::)*; (?s)^(?:COMPAT_)?SYSCALL_DEFINE.\(ARRAY_END\b[\w\s,;[\]*\?:+-]*\)[ \t]*\n*(?[ \t]*){.*?^\k} (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?_IO_ARRAY_END\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))(?:[\w\s\(,\)[\]]|::)*; (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?M_DECL_FUNC \(__ARRAY_END\)\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))[ \t]*\n*(?[ \t]*){.*?^\k} (?s)^[\w[](?:[\w\s\(,\)[\]*]|::)+[\w\s\)*\]]\s+\**\(?_IO_ARRAY_END\)?\s*(?\((?:[\w\s,;[\]*\?:+-]|(?¶ms))*(?:\.\.\.)?\))[ \t]*\n*(?[ \t]*){.*?^\k} (?s)^[ \t]*#\s*define\s[\s\\]*ARRAY_END\b\([^\(]*\)(?:(?![^\\]$).)*.*?(?[ \t]*){.*?^\k}[^;]*; (?s)^[ \t]*typedef\s+[^{};]+\bARRAY_END; (?s)^[ \t]*typedef\s+(?:struct|union|enum)\b[\w \t[\]:]*[ \t]*\n*(?[ \t]*){.*?^\k}\s*ARRAY_END(?:\[[\w\(,\)]\])*; (?s)^[ \t]*typedef\s+[^{};]+\(\**ARRAY_END\)\s*\([^{};]+; $ grepc_c -tfld open (?s)^(?:COMPAT_)?SYSCALL_DEFINE.\(open\b[\w\s,;[\]*\?:+-]*\)[ \t]*\n*(?[ \t]*){.*?^\k} And those regexes can actually be used by git-grep(1) with -P (and -f): $ grepc_c -tm ARRAY_END (?s)^[ \t]*#\s*define\s[\s\\]*ARRAY_END\b\([^\(]*\)(?:(?![^\\]$).)*.*?(?