我在vim中苦苦掙扎。
我還沒有找到我如何可以從python腳本(在vim函數中)將值導回到vim p.e.在vimscript中使用Python:如何將值從python腳本導出回vim?
function! myvimscript()
python << endpython
import vim, random, sys
s = vim.eval("mylist")
# do operation with variable "s" in python
endpython
" import variable "s" from above
" do operation with "s" in vimscript
endfunction
1)如何能在我的vim再次使用"s"
(我怎麼可以導入"s"
從Python代碼回到VIM)?
我無法找到如何使用vim.current.buffer與選擇。
function! myvimscript()
let startline = line("'<")
let endline = line("'>")
python << endpython
start = vim.eval("startline")
end = vim.eval("endline")
cb = vim.current.buffer
l = cb[start:end]
endpython
endfunction
2)我怎樣才能分配動態值"start"
和"end"
到"l"
這是一個從bash腳本運行的python腳本嗎? –
@TallPaul,Un pythonscript在vimscript中運行(並用vimrc中的地圖調用) – Reman
相關:[如何從Python&Vimscript中的函數返回值?](http://stackoverflow.com/q/ 16756613)。 – glts