Following the suggestion of @filbranden you could do: ``` function! Rename(old_path, new_path) abort let c=&confirm set noconfirm try execute "saveas" fnameescape(a:new_path) catch /File exists/ echo 'fail to rename to: ' . fnameescape(a:new_path) return finally let &confirm = c endtry call delete(a:old_path) endfunction ``` Remark: I propose to temporarily disable the `noconfirm` option such that the exception is raised.