diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-21 00:01:53 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-05-21 00:01:53 +1200 |
commit | 961e50bfc2128e04c7771ee0150d9024f5616987 (patch) | |
tree | f60cadba0b806a8671621ec45efead14ee57d54e /plugin/shebang_change_filetype.vim | |
download | vim-shebang-change-filetype-961e50bfc2128e04c7771ee0150d9024f5616987.tar.gz vim-shebang-change-filetype-961e50bfc2128e04c7771ee0150d9024f5616987.zip |
First versionv0.1.0
Diffstat (limited to 'plugin/shebang_change_filetype.vim')
-rw-r--r-- | plugin/shebang_change_filetype.vim | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugin/shebang_change_filetype.vim b/plugin/shebang_change_filetype.vim new file mode 100644 index 0000000..ca6c183 --- /dev/null +++ b/plugin/shebang_change_filetype.vim @@ -0,0 +1,25 @@ +" +" shebang_change_filetype.vim: On leaving insert mode, check whether the first +" line was changed and looks like a shebang format. +" +" Author: Tom Ryder <tom@sanctum.geek.nz> +" License: Same as Vim itself +" +if exists('loaded_shebang_change_filetype') || &compatible + finish +endif +if !has('autocmd') || v:version < 700 + finish +endif +let loaded_shebang_change_filetype = 1 + +" Set up hook for before writes to check the buffer for new shebangs +augroup shebang_change_filetype + autocmd! + autocmd InsertLeave * + \ call shebang_change_filetype#Check() + if exists('##TextChanged') + autocmd TextChanged * + \ call shebang_change_filetype#Check() + endif +augroup END |