インタフェースは呪われているすべての非vimscript:(Pythonでvim.command(string)
)execute
とeval
をしている(編集する場合を除き/バッファオブジェクトを使用して利用可能であるバッファの内容を取得)のvimと通信するための唯一の方法(vim.eval(string)
でPython)、どちらも直列化の引数が必要です。あなただけのビジュアルモードでの使用に
vim.command("normal! V")
または
vim.eval("feedkeys('V')")
を開始したい場合。しかし、例えば、呼び出し元関数にある値を返すことが必要な場合は、
import json
# Some code that puts result into variable r
# This won't work if r contains non-unicode strings,
# you will have to write your own serializer in this case.
# As far as I know, it will also fail if some characters in the string
# can be represented only using surrogate pairs.
vim.command("let reply=".json.dumps(r))
# Now in the caller function variable l:reply is defined
出典
2011-10-23 09:34:56
ZyX
のようにすることができますか?そのようなPythonインターフェイスから通常のV2jx "'を実行できませんか? – ninjalj