I'm using grep in vim to do something such as:
:grep pattern file
and have a key-map for it that looks like that:
function! Escaped() call inputsave() let result = escape(@", '\\/.*$^~#') let result = substitute(result, "\n$", "", "") let result = substitute(result, "\n", '\\n', "g") call inputrestore() return result endfunction xnoremap <silent> <unique> * y:grep "<C-r>=Escaped()<CR>" file
This does work great but I want to open the result of this command in a split window instead.
I tried inserting
split and such at the start of the command, or before grep, but it doesn't seem to work.
Quickfix does seem to work, but since it keeps old matches I would prefer for it to be either deleting the old match, or (as the question suggests) opening the result in a split window in vim (without tmux etc)
How could I do that?