I have the following code to copy the file I am editing to another folder, but when execute the command by press F5, it tries to do command "copy path newpath" literally without replace the variables with the their value. What's the solution?
function! Cpf()
let path = expand('%:p')
echo path
echo "123"
let newpath = substitute(path,'test1','test2','g')
echo "copy " path newpath
:!copy path newpath
endfunction
:map <F5> :call Cpf()<CR>