Skip to content

Instantly share code, notes, and snippets.

@stephenmm
Created July 11, 2013 20:37
Show Gist options
  • Save stephenmm/5979019 to your computer and use it in GitHub Desktop.
Save stephenmm/5979019 to your computer and use it in GitHub Desktop.
RenameCurrentFile with auto-completion
function! RenameCurrentFile(newName)
let l:currentFile = expand("%:p")
silent! exe "saveas " . a:newName
if delete(l:currentFile)
echoerr "Could not delete " . l:currentFile
endif
endfunction
command! -nargs=1 -complete=file -bang RenameCurrentFile :call RenameCurrentFile("<args>")
noremap <Leader>rf :RenameCurrentFile <C-R>=expand("%:p")<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment