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 | |
| redraw! | |
| endif | |
| endfunction | |
| map <leader>N :call RenameFile()<cr> |