Skip to content

Instantly share code, notes, and snippets.

@shime shime/_readme.md
Created Nov 28, 2013

Embed
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.

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
You can’t perform that action at this time.