Skip to content

How to escape double underscore and single underscore in rg. #2324

Answered by BurntSushi
jianhe-fun asked this question in General
Discussion options

You must be logged in to vote

This is almost certainly an instance of the XY problem. Namely, underscores never need to be escaped because they are not meta characters:

$ echo '#define FLT_DIG __FLT_DIG__' | rg __FLT_DIG__
#define FLT_DIG __FLT_DIG__

So if rg __FLT_DIG__ isn't showing the matches you expect, then it's almost certainly because of some other problem. You'll need to either provide a complete reproduction, and/or take a look at the --debug output. Remember, as the very first lines of the ripgrep docs state, ripgrep will by default ignore things matching your gitignore, hidden files and binary files.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants