0

Trying to search in vim using ripgrep :Rg for e.g. '||'.

Have tried:

:Rg --hidden --no-ignore '||'
:Rg --hidden --no-ignore '\|\|'
:Rg --hidden --no-ignore "||"
:Rg --hidden --no-ignore "\|\|"

But it just matches every column of every line.

According to the manual you can use --fixed-strings, but when I do

:Rg --fixed-strings --hidden --no-ignore '||'
:Rg --fixed-stringsssssssssssssssssss --hidden --no-ignore '||'

It still ignores any number of 's' to complain

 1 || error: Found argument '--fixed-string' which wasn't expected, or isn't valid in this context
 2 ||  Did you mean --fixed-strings?
 3 ||
 4 || USAGE:
 5 ||
 6 ||     rg [OPTIONS] PATTERN [PATH ...]
 7 ||     rg [OPTIONS] [-e PATTERN ...] [-f PATTERNFILE ...] [PATH ...]
 8 ||     rg [OPTIONS] --files [PATH ...]
 9 ||     rg [OPTIONS] --type-list
10 ||     command | rg [OPTIONS] PATTERN
11 ||
12 || For more information try --help
13 ||

How do I use Vim Ripgrep to search for ||?

xxjjnn
  • 14,591
  • 19
  • 61
  • 94
  • Doing `rg '\|\|'` in the console works as expected. Just when Vim is trying to ripgrep there is problem ლ(ಠ益ಠლ) – xxjjnn Nov 09 '21 at 14:50
  • 1
    Maybe this is because of (insane) Vim escaping rules, which add to the escaping required by `rg` (the external program) itself? The command is defined [like so](https://github.com/jremmen/vim-ripgrep/blob/ec87af6/plugin/vim-ripgrep.vim#L148): `command! -nargs=* -complete=file Rg :call s:Rg()`, I’d suggest you check Vim’s manual for the escaping rules induced by that. Sorry… The `--fixed-strings` issue, on the other hand, looks like a bug in the plugin; try to report it perhaps? – Maëlan Nov 09 '21 at 16:03
  • 1
    Maybe try: `\\|\\|` – mattb Nov 09 '21 at 18:18
  • 1
    Aha that worked! I'd tried `\\\|\\\|` but not `\\|\\|` ⊂(´・◡・⊂ )∘˚˳° Put as answer – xxjjnn Nov 10 '21 at 11:24

0 Answers0