Skip to content

Instantly share code, notes, and snippets.

@shime shime/
Created Nov 28, 2013

What would you like to do?
easier renaming and moving of files in vim

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


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
map <leader>N :call RenameFile()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.