1
0
Fork 0

Initial commit

This commit is contained in:
Andrew Tomaka 2016-08-15 22:37:12 -04:00
commit af4c1b8b0d
2 changed files with 22 additions and 0 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
# renamefile.vim
This function, ripped directly from [Gary Bernhardt's dotfiles](https://github.com/garybernhardt/dotfiles)
renames a file in place.
## Usage
This plugin adds the command `:RenameFile`. When called, it will prompt you for
a new file name. If the filename is blank or the same as the previous file
name, nothing will happen. If the new name is different, the file will be
saved as the new name and the old file will be delated.

11
plugin/renamefile.vim Normal file
View File

@ -0,0 +1,11 @@
function! s: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
command! RenameFile call <SID>RenameFile()