Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: dff0d19aae
Fetching contributors…

Cannot retrieve contributors at this time

file 24 lines (19 sloc) 0.584 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24



" Rename buffer and file in one go
" By Christian J. Robinson
" http://www.vim.org/scripts/script.php?script_id=1928

command! -nargs=* -complete=file -bang Rename :call Rename("<args>", "<bang>")

function! Rename(name, bang)
let l:curfile = expand("%:p")
let v:errmsg = ""
silent! exe "saveas" . a:bang . " " . a:name
if v:errmsg =~# '^$\|^E329'
if expand("%:p") !=# l:curfile && filewritable(expand("%:p"))
silent exe "bwipe! " . l:curfile
if delete(l:curfile)
echoerr "Could not delete " . l:curfile
endif
endif
else
echoerr v:errmsg
endif
endfunction
Something went wrong with that request. Please try again.