Thank you ZyX, Can you please tell me where to put string.encode(vim.options['encoding'])? Before searchpos()? And decode(vim.options['encoding'])after searchpos()?
Let say I create my list "MyPositions" with start/end position of matches using searchpos() in vim.
Then in my python code I have to do something like this to convert it to byte strings:
python3 << endpython
import vim
myposPyth = str(vim.eval("MyPositions"))
myposPyth = myposPyth.encode(vim.options['utf8'])
?
I still don't get it.
(btw above returns a key-error)
BTW I thought that ['encoding'] was a placeholder for utf8/latin1.
You seems to know everything in every computer language :)
Yes I use Pyth3 and many times also `vim.current.buffer[linenr-1]`
or things like this `r = vim.current.buffer[startline:endline]`
To avoid decoding errors it is better to switch all these statements to:
vim.Function('getline')(linenr) ?
p.e. line 3 in vim: vim.current.buffer[2]` --> vim.Function('getline')(2)?
How does python know from which buffer it has to capture the line and what would be the vim.Function statement in this case with a slice: `vim.current.buffer[startline:endline]`?
My experience with Python tells me that Python language is much easier then vimscript. Things can be done easier with the many Python modules using less code then in vimscript. Even Python regex is much easier (p.e. lookahead/behind). I wish both language were more compatible. ;)