Can I insert a tab in the replace text ? eg. -or '$1\t$2' #1953
-
Now using '$1\t$2' results in : [group1]\t[group2] , not [group1] [group2] |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You can, but you have to insert it literally. The replacement directive doesn't support escape sequences. Inserting it literally depends on your terminal/shell environment. In my environment, if I hit |
Beta Was this translation helpful? Give feedback.
-
An option that allows you to use $ cat example.txt
foo="this is foo" hello _bar="this is bar" bye
hmm hi foo="more foo" but bar="more bar" ok... $ rg -P '^.*foo="(.*)".*bar="(.*)".*$' --replace=$'\n${1}\t${2}\n\n'
./example.txt:
this is foo this is bar
./example.txt:
more foo more bar
As shown above, you can also use |
Beta Was this translation helpful? Give feedback.
You can, but you have to insert it literally. The replacement directive doesn't support escape sequences. Inserting it literally depends on your terminal/shell environment. In my environment, if I hit
CTRL-v
, release it, and then pressTAB
, it will insert a literal tab character.