shebang ( ファイル先頭の #!/bin/sh とか )でカレントバッファのファイルを実行する関数。
function! ShebangExecute()
let m = matchlist(getline(1), '#!\(.*\)')
if(len(m) > 2)
execute '!'. m[1] . ' %'
else
execute '!' &ft ' %'
endif
endfunction
適当にキーバインド設定してやると便利である。
nmap ,e :call ShebangExecute()<CR>