aboutsummaryrefslogblamecommitdiff
path: root/plugin/shebang_change_filetype.vim
blob: b900042fe90ebb6d16e2ecb52e05ec250de738e2 (plain) (tree)
1
2
3
4
5
6
7
8
 

                                                                           



                                         
                                                                             







                                                                    
                                         

                            
                                                         

           
"
" 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 shebang_change_filetype InsertLeave
  endif
augroup END