I want to organize my vimrc better, so I want to put all the custom functions at bottom:
"different setting between different os
if MyDetectOS() ==? "windows"
set rtp+=~/vimfiles/bundle/Vundle.vim/
let path='~/vimfiles/bundle'
else
set rtp+=~/.vim/bundle/Vundle.vim
endif
if MyDetectOS() ==? "linux"
set clipboard=unnamedplus
else
set clipboard=unnamed
endif
function! MyDetectOS()
if has("win32") || has("win16") || has("win64")
return "windows"
elseif has("mac") || has("macunix")
return "mac"
elseif has("win32unix")
return "cygwin"
elseif has("unix")
let l:uname = substitute(system("uname"), '\n', '', '')
if l:uname ==? "linux"
return "linux"
else
return "unix"
endif
endif
endfunction
If I put the MyDetectOS
function at bottom like above. Then I'll get errors like below:
E117: Unknown function: MyDetectOS
E15: Invalid expression: MyDetectOS() ==? "linux"
Why it doesn't work?