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 runtime! ftplugin/programming_lang.vim setlocal keywordprg=pydoc 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 elseif ext == "ptl" !compyle-ptl % else !compyle % if ext != "py" !rm -f %[co] endif if getline(1) =~ "^#!" call SetExecutableBit(1) endif endif endfunction " Avoid double indent. See https://stackoverflow.com/a/62348570/7976758 let g:pyindent_open_paren=shiftwidth()