aboutsummaryrefslogtreecommitdiff
path: root/autoload/shebang_change_filetype.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/shebang_change_filetype.vim')
-rw-r--r--autoload/shebang_change_filetype.vim7
1 files changed, 7 insertions, 0 deletions
diff --git a/autoload/shebang_change_filetype.vim b/autoload/shebang_change_filetype.vim
new file mode 100644
index 0000000..081eaf1
--- /dev/null
+++ b/autoload/shebang_change_filetype.vim
@@ -0,0 +1,7 @@
+" Check whether the first line was changed and looks like a shebang, and if
+" so, re-run filetype detection
+function! shebang_change_filetype#Check() abort
+ if line('''[') == 1 && getline(1) =~# '^#!'
+ doautocmd filetypedetect BufRead
+ endif
+endfunction