fork download
function! CopyFiltered()
    let buffer = join(getbufline(bufname("%"), 1, "$"), "\n")
    let buffer = substitute(buffer, "foo", "BAR", "g")
    call setreg("*", buffer)
endfunction
noremap Y :call CopyFiltered()
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout

Standard output is empty