Skip to content

Instantly share code, notes, and snippets.

@andrewle
Created June 15, 2012 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewle/2939200 to your computer and use it in GitHub Desktop.
Save andrewle/2939200 to your computer and use it in GitHub Desktop.
Vim rename file
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment