I would like to put <Leader>a on a search with ag word under the cursor
I wrote this:
noremap <Leader>a :Ag!<Cu><Cr>=Escape(expand('<cword>'))<CR> function! Escape(stuff) return substitute(escape(a:stuff, '\/.*$^~[]'), "\n", '\\n', "g") endfunction
Unfortunately, when I pressed <Leader>a on the word foo , I get the following:
:foo
Ag! disappeared and the final <CR> not executed.
Where is my mistake?
source share