I am using AG to simplifying and improve the search in my Vim. I remapped K to search for the current selected word as follows:
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
command -nargs=+ -complete=file -bar Ag silent! grep! <args>|cwindow|redraw!
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR>
nnoremap ff :Ag<SPACE>
endif
However this doesn't work as expected. When I hit the keyboard K, a small windows opens up in the bottom, showing the following message:
Then, I hit Enter and it goes to the results. How can I avoid this window message and go directly to the result page?
<CR>
at the end of mapping:nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR><CR>
.nnoremap <silent> K ...
, this will prevent you from seeing the shell output fromag
. I'm not sure if this is the 'proper' way to fix this, though.