aboutsummaryrefslogtreecommitdiff
path: root/plugin/shebang_change_filetype.vim
blob: 69a4ad52e88e88be3fb72c813eb1a5185ce891d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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#()
  if exists('##TextChanged')
    autocmd TextChanged *
          \ call shebang_change_filetype#()
  endif
augroup END