aboutsummaryrefslogtreecommitdiff
path: root/modules/vim/vim.dot.link/plugin/Rename.vim
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-02-01 01:25:10 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-02-01 01:25:10 -0200
commit6b9187673ee62d11042832f938913f15131592a7 (patch)
tree9e70016667efe273a72ab351aafaddbdb099e123 /modules/vim/vim.dot.link/plugin/Rename.vim
parent25235935e6c90557a4d6791c8d8f3a5cdf89681a (diff)
downloaddotfiles-6b9187673ee62d11042832f938913f15131592a7.tar.gz
dotfiles-6b9187673ee62d11042832f938913f15131592a7.tar.bz2
Adding metadot script
Diffstat (limited to 'modules/vim/vim.dot.link/plugin/Rename.vim')
-rw-r--r--modules/vim/vim.dot.link/plugin/Rename.vim27
1 files changed, 27 insertions, 0 deletions
diff --git a/modules/vim/vim.dot.link/plugin/Rename.vim b/modules/vim/vim.dot.link/plugin/Rename.vim
new file mode 100644
index 0000000..b56c516
--- /dev/null
+++ b/modules/vim/vim.dot.link/plugin/Rename.vim
@@ -0,0 +1,27 @@
+" Rename.vim - Rename a buffer within Vim and on the disk
+"
+" Copyright June 2007 by Christian J. Robinson <infynity@onewest.net>
+"
+" Distributed under the terms of the Vim license. See ":help license".
+"
+" Usage:
+"
+" :Rename[!] {newname}
+
+command! -nargs=* -complete=file -bang Rename :call Rename("<args>", "<bang>")
+
+function! Rename(name, bang)
+ let l:curfile = expand("%:p")
+ let v:errmsg = ""
+ silent! exe "saveas" . a:bang . " " . a:name
+ if v:errmsg =~# '^$\|^E329'
+ if expand("%:p") !=# l:curfile && filewritable(expand("%:p"))
+ silent exe "bwipe! " . l:curfile
+ if delete(l:curfile)
+ echoerr "Could not delete " . l:curfile
+ endif
+ endif
+ else
+ echoerr v:errmsg
+ endif
+endfunction