How should I rename my current file in Vim?
For example:
person.html_erb_spec.rb
person
There’s a function in Gary Bernhardt’s .vimrc that handles this.
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 n :call RenameFile()