ciw'Ctrl+r"'
-
ciw
- Delete the word the cursor is on, and end up in insert mode. -
'
- add the first quote. -
Ctrl+r"
- Insert the contents of the " register, aka the last yank/delete. -
'
- add the closing quote.
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>r :call RenameFile()<cr>