The official Vim python interface documentation states, that modifying buffers with python is very simple, basically:
:py import vim
:py vim.current.buffer[0] = "Hello world"
However, python throws an exception, when I try to do that:
Traceback (most recent call last):
File "<string>", line 1, in <module>
TypeError: bad argument type for built-in operation
Read-only access (e.g. :py print vim.current.buffer[0] works just fine. Am I missing something here? Why can’t I modify vim buffers with python scripts?
[Note: I’m using recent Vim 7.3]
Works for me, “Hello World” is inserted in buffer. Is your vim compiled with
+pythonI’m using version 7.3.162
EDIT
looking in the hg log for
if_python.cI see a lot issues related to python, e.g. this one:Which version are you on?