Skip to content

Instantly share code, notes, and snippets.

@shime
Created November 28, 2013 14:25
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 shime/7692690 to your computer and use it in GitHub Desktop.
Save shime/7692690 to your computer and use it in GitHub Desktop.
easier renaming and moving of files in vim

Simple function that makes moving and renaming files in Vim much easier.

Usage

Place it in your ~/.vimrc.

I'm calling it with <leader>N here, map it to anything you like.

function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
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