On 13/05/10 09:40, 0x0renegat0x0 wrote:

Hi

I don't like vim syntax for writing scripts (set let a: g:variable). I
choose to use python environment for writing things in vim.

However I've encountered some problems.

One:
I have access to buffers from vim python object. However I don't know if I
can add buffer via vim objects or if this object is only for accessing the
buffers.

I cannot inherit Vim object. That is why I created my own wrapper for vim
native functions (line, getline, setline). I do that by vim.eval() command.
The problem is that to write into a buffer I have to switch into other
buffer and then I have to call in a loop setline which can only write into
current buffer.

My Write function in python makes vim call by vim.eval() as following
:b1 (select buffer1)
getline(...)
setline(...)
setlocal(...)
:b4 (select previous buffer)

When I am writing a lot of data to the buffer it takes time. It is too long
for me to accept. The speed of execution is only determined by python
environment? Or I shouldn't be using eval function, or is there any way to
speed things up?


For maximum efficiency and, most especially, portability, I would recommend to learn Vim commands. They aren't really difficult, and their documentation (the Vim help) is really top-class. Oh, the Perl, Python, etc., interfaces do work, if you have them compiled-in and, if dynamically linked, if you have the right versions of the libraries available. But using them means exchanging messages both ways between the Perl, Python, etc. interpreter and the Vim editor _in addition_ to whatever tasks the interpreter and the editor normally do.

You _can_ use vim.command("edit foobar.py") in a python script to start editing the file foobar.py (which will then be your current buffer, unless Vim isn't willing to |abandon| (q.v.) the file you were editing previously and raises an exception); but if you open a new buffer by typing

        :py vim.command("edit foobar.py")

at the command-line (which is valid if Vim was compiled with +python, the python libs are available, and you've already imported the vim module into the python side of the interface), I will start thinking that your preferred path from London to Westminster is through Rome.


Best regards,
Tony.
--
Philadelphia is not dull -- it just seems so because it is next to
exciting Camden, New Jersey.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to