aboutsummaryrefslogtreecommitdiff
path: root/plugin/shebang_change_filetype.vim
blob: 03f58308512742d85bae95485c9d4443e8b8d138 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
"
" shebang_change_filetype.vim: Re-run filetype detection if a shebang #! is
" added or changed in the buffer.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if exists('loaded_shebang_change_filetype') || &compatible || 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 *
          \ doautocmd InsertLeave
  endif
augroup END