From 591fb00529618f58fdbdc6a6c4fc22c1c9e4b29f Mon Sep 17 00:00:00 2001 From: Sebastian Humenda Date: Sun, 23 Feb 2020 20:58:13 +0100 Subject: [PATCH] Quote ripgrep arguments to be able to use special characters in regex --- plugin/vim-ripgrep.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/vim-ripgrep.vim b/plugin/vim-ripgrep.vim index 9bc029d..deb255f 100644 --- a/plugin/vim-ripgrep.vim +++ b/plugin/vim-ripgrep.vim @@ -61,7 +61,9 @@ fun! s:RgSearch(txt) if &smartcase == 1 let l:rgopts = l:rgopts . '-S ' endif - silent! exe 'grep! ' . l:rgopts . a:txt + " quote a:txt before sending it to the shell + let l:txt = substitute(a:txt, "'", "\\'", "g") + silent! exe 'grep! ' . l:rgopts . "'" . a:txt . "'" if len(getqflist()) exe g:rg_window_location 'copen' redraw!