aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-09-20 23:51:56 +0200
committersrdusr <trevorgray@srdusr.com>2023-09-20 23:51:56 +0200
commit27d7b85ed4bcb2902474dd248fe0e2c7ab233179 (patch)
tree9e1208f2942fbb434a5da42c9f4a4aaf4adbb12d
parent79fe8f59f3062d7489c14ba0421704ff0b85e8f0 (diff)
downloaddotfiles-27d7b85ed4bcb2902474dd248fe0e2c7ab233179.tar.gz
dotfiles-27d7b85ed4bcb2902474dd248fe0e2c7ab233179.zip
Rename file
-rw-r--r--autoload/utils.vim26
1 files changed, 20 insertions, 6 deletions
diff --git a/autoload/utils.vim b/autoload/utils.vim
index 1eeba25..69ef640 100644
--- a/autoload/utils.vim
+++ b/autoload/utils.vim
@@ -212,12 +212,26 @@ endfunction
"-------------------------------------------------
" On The Fly Table mode
- function! s:isAtStartOfLine(mapping)
- let text_before_cursor = getline('.')[0 : col('.')-1]
- let mapping_pattern = '\V' . escape(a:mapping, '\')
- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
- endfunction
+function! s:isAtStartOfLine(mapping)
+ let text_before_cursor = getline('.')[0 : col('.')-1]
+ let mapping_pattern = '\V' . escape(a:mapping, '\')
+ let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
+ return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
+endfunction
+
+
+"-------------------------------------------------
+
+" :Rename {newname}
+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
"-------------------------------------------------