Bu pasajı hangi Python sürümünü belirleyebilir biz kullanıyorsun ve ona geçin (Python bu sürümün yüklü olduğu anlamına gelir).
if has('python')
command! -nargs=1 Python python <args>
elseif has('python3')
command! -nargs=1 Python python3 <args>
else
echo "Error: Requires Vim compiled with +python or +python3"
finish
endif
öncelikle (Vim Script gibi aynı dizin altında burada) yerini anlamaya, piton kodunu yüklemek için: piton modülü varsa
execute "Python import sys"
execute "Python sys.path.append(r'" . expand("<sfile>:p:h") . "')"
Sonra kontrol edin. Değilse, bunu yeniden:
Python << EOF
if 'yourModuleName' not in sys.modules:
import yourModuleName
else:
import imp
# Reload python module to avoid errors when updating plugin
yourModuleName = imp.reload(yourModuleName)
EOF
iki yol adlandırmak:
1.
" call the whole module
execute "Python yourModuleName"
" call a function from that module
execute "Python yourModuleName.aMethod()"
2.
" Call a method using map
vnoremap <leader> c :Python yourModuleName.aMethod()<cr>
" Call a module or method using Vim function
vnoremap <leader> c :<c-u> <SID>yourFunctionName(visualmode())<cr>
function! s:YourFunctionName(someName)
Python YourFunctionName.aMethod(a:someName)
Python YourFunctionName
endfunction
kısa cevap hayır. Daha uzun bir cevap ise, Python'un hangi sürümünün mevcut olduğunu test ederek, bir değişkeni "py" ya da "python" ya da "python3" şeklinde ayarlayıp bunu exec pod ile çağırarak özetleyebilirsiniz. 'yazdır ("EAT ME")' '. Evet, iyi olduğunu söylemedim. – lcd047