Closed kis9a closed 2 years ago
I am escaping the characters manually, like '\[\[" . fname . "\]]'. but, But if fame also contains characters that must be escaped, it's very difficult.
function! s:ObsidianRgNotesWithMatches(word) abort let cmd = 'cd ' . g:obsidian_path . "; rg -n %s --files-with-matches" . "| awk '" . '{ print $0 ":1: " }' . "'" ... function! s:ObsidianRgNotesLinkingThisNote() abort let fname = fnamemodify(expand("%:t"), ":r") let ext = expand("%:e") if ext == "md" let a=s:ObsidianRgNotesWithMatches("'\\[\\[" . fname . "\\]]'") else let a=s:ObsidianRgNotesWithMatches("'\\[\\[" . expand("%t") . "\\]]'") endif endfunction
Found a issue talking about this. In my case the -F flag seems to work. Option flag to automatically escape regex #299
I am escaping the characters manually, like '\[\[" . fname . "\]]'. but, But if fame also contains characters that must be escaped, it's very difficult.