if exists("b:did_ftplugin") finish endif " Do not set b:did_ftplugin - it prevents standard plugins from running " let b:did_ftplugin = 1 " it will be set in the standard plugin if has("iconv") && !exists('b:encoding_set') " Try to recognize the file encoding and convert the file let line = getline(1) if line !~ '^ *#.*coding[=:]\s*\([-0-9A-Za-z_.]\+\)' let line = getline(2) endif if line =~ '^ *#.*coding[=:]\s*\([-0-9A-Za-z_.]\+\)' let encoding = matchlist(line, 'coding[=:]\s*\([-0-9A-Za-z_.]\+\)')[1] call SetupEncoding(encoding) endif endif setlocal formatoptions-=t formatoptions+=croql setlocal keywordprg=pydoc setlocal shiftwidth=4 softtabstop=4 compiler python if has("unix") autocmd BufWritePost call SavePython() endif " Compile and remove *.cgi[co] files after compilation; do not remove *.py[co] files; " if it is a shebang script change file mode to make it executable. function! SavePython() let ext = expand("%:e") if ext == "pyem" return elif ext == "ptl" !compyle-ptl % else !compyle % if ext != "py" !rm -f %[co] endif if executable(expand('%:p')) || !executable('chmod') return endif if getline(1) =~ "^#!" !chmod +x % if v:shell_error echoerr 'Cannot make file executable: ' . v:shell_error endif endif endif endfunction