diff options
-rw-r--r-- | vim/autoload/shebang.vim | 7 | ||||
-rw-r--r-- | vim/plugin/shebang_update.vim | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/vim/autoload/shebang.vim b/vim/autoload/shebang.vim new file mode 100644 index 00000000..f39fcf48 --- /dev/null +++ b/vim/autoload/shebang.vim @@ -0,0 +1,7 @@ +" If the first line was changed in the last insert operation, re-run script +" detection +function! shebang#Update() abort + if line("'[") == 1 + runtime scripts.vim + endif +endfunction diff --git a/vim/plugin/shebang_update.vim b/vim/plugin/shebang_update.vim new file mode 100644 index 00000000..1dbcaf67 --- /dev/null +++ b/vim/plugin/shebang_update.vim @@ -0,0 +1,20 @@ +" +" shabeng_update.vim: If the first line of a file was changed, re-run +" scripts.vim to do shebang detection to update the filetype. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('g:loaded_shebang_update') || &compatible + finish +endif +if v:version < 700 + finish +endif +let g:loaded_shebang_update = 1 + +" Call the update function whenever leaving insert mode +augroup shebang_update + autocmd! + autocmd InsertLeave * call shebang#Update() +augroup END |