I began to get the error
Error detected while processing BufRead Auto commands for "*.sh":
E117: Unknown function: dist#ft#SetFileTypeSH
when I opened shell scripts (*.sh) I think it happened after updating from a 7.x version to 8.0.
How can it be fixed?
As suggested, I did a search for the function in /usr/share/vim/vim80/autoload/dist/ft.vim
" Called from filetype.vim and scripts.vim.
func dist#ft#SetFileTypeSH(name)
if expand("<amatch>") =~ g:ft_ignore_pat
return
endif
if a:name =~ '\<csh\>'
" Some .sh scripts contain #!/bin/csh.
call dist#ft#SetFileTypeShell("csh")
return
elseif a:name =~ '\<tcsh\>'
" Some .sh scripts contain #!/bin/tcsh.
call dist#ft#SetFileTypeShell("tcsh")
return
elseif a:name =~ '\<zsh\>'
" Some .sh scripts contain #!/bin/zsh.
call dist#ft#SetFileTypeShell("zsh")
return
elseif a:name =~ '\<ksh\>'
let b:is_kornshell = 1
if exists("b:is_bash")
unlet b:is_bash
endif
if exists("b:is_sh")
unlet b:is_sh
endif
elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
let b:is_bash = 1
if exists("b:is_kornshell")
unlet b:is_kornshell
endif
if exists("b:is_sh")
unlet b:is_sh
endif
elseif a:name =~ '\<sh\>'
let b:is_sh = 1
if exists("b:is_kornshell")
unlet b:is_kornshell
endif
if exists("b:is_bash")
unlet b:is_bash
endif
endif
call dist#ft#SetFileTypeShell("sh")
endfunc
Is anything wrong with it?
I also noticed that syntax highlighting stopped working too.
I noticed that if I don't use the session file vim can open shell scripts without errors.
I think the session file is the culprit. There must be some backwards compatibility problems between versions 8 and 7 as the session file worked fine in VIM 7. But how to locate the error... I don't want to create the session file from scratch.
:e $VIM/vim80/autoload/dist/ft.vimand search forSH—you should find the function. If it’s not there or you are missing the file, you may need to reinstall vim or its runtime files. It may bevim81if you are using 8.1. – D. Ben Knoble Aug 19 '18 at 20:43:echo $VIMRUNTIME– tivn Aug 21 '18 at 07:00