Following the suggestion of @filbranden you could do: ``` function! Rename(old_path, new_path) abort try execute "saveas" fnameescape(a:new_path) catch /File exists/ echo 'fail to rename to: ' . fnameescape(a:new_path) return endtry call delete(a:old_path) endfunction ```