FAQ
I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few
more hacks, I think it all looks good.

I need some help to make it professional.

It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few
hours... =)
If you can get it to compile (just edit the Makefile to make it point to
the right place...) try this with Vim 6.0:

$ gvim --servername TEST
$ python
import vim
vim.list()
['TEST']
vim.send('TEST', 'iHello World!<ESC>')
You should see the string "Hello World!" neatly typed into the newly opened
vim window!!!

Sorry, X11 only right now...

Jonathan

[ Note: This was cross-posted to vim-dev and python-list so I can go to bed
sooner... ]

Search Discussions

  • Jonathan Gardner at Nov 13, 2001 at 12:32 am

    On Tuesday 13 November 2001 02:00 am, Jonathan Gardner wrote:
    It's 2:00 AM here in Seoul, so I won't be getting any answers out for a
    few hours... =)
    If you can get it to compile (just edit the Makefile to make it point to
    the right place...) try this with Vim 6.0:
    Now it's 9:30 AM in Seoul, and somebody told me that I didn't attach
    anything. Sorry all! Here is the software attached.

    Jonathan
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: python_vim.tar.gz
    Type: application/x-gzip
    Size: 5815 bytes
    Desc: The stuff
    Url : http://mail.python.org/pipermail/python-list/attachments/20011113/889cd6a1/attachment.bin
  • Benoit Cerrina at Nov 13, 2001 at 2:49 am
    Looking at Jonathan Gardner python module I wondered:
    This may be a good time to ask why is there a if_xcmdsrv.c and
    no if_w32cmdsrv.c with all the client server code fow windows folded
    in os_mswin.c?
    Benoit
  • Jonathan Gardner at Nov 13, 2001 at 1:11 pm

    Benoit Cerrina wrote:
    Looking at Jonathan Gardner python module I wondered: This may be a good
    time to ask why is there a if_xcmdsrv.c and no if_w32cmdsrv.c with all the
    client server code fow windows folded in os_mswin.c?
    Benoit
    Simple - I don't have a windows box. This was written a couple of days ago,
    so it is bleeding edge, and probably hemmorhaging due to the fact I am new
    to this.

    Would you like to do it? I'm putting the stuff up at sourceforge for anyone
    to play with. Open Source is the way to go, eh?

    The codebase for the module is heavily dependent on X11. The one for windows
    will be entirely different because it would have to use Win32.

    Jonathan
  • Jonathan Gardner at Nov 13, 2001 at 1:07 pm

    Jonathan Gardner wrote:
    On Tuesday 13 November 2001 02:00 am, Jonathan Gardner wrote: It's 2:00
    AM here in Seoul, so I won't be getting any answers out for a few
    hours... =) If you can get it to compile (just edit the Makefile to make
    it point to the right place...) try this with Vim 6.0:
    Now it's 9:30 AM in Seoul, and somebody told me that I didn't attach
    anything. Sorry all! Here is the software attached.
    Man, I feel really stupid... first I don't attach anything, and then I
    attached a bad set of files. This time I triple-checked it, so it should
    work with only a little bit of tinkering.

    Jonathan
    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: python_vim.tar.gz
    Type: application/x-gzip
    Size: 10020 bytes
    Desc: This one should really work!
    Url : http://mail.python.org/pipermail/python-list/attachments/20011113/27d82e2a/attachment.bin
  • Simonb at Nov 14, 2001 at 12:19 am
    Well this sounds interesting...

    i compiled vim60 with
    CONF_OPT_PYTHON = --enable-pythoninterp
    in the Makefile,
    but "import vim" fails.
    what next?

    Simon Burton


    Jonathan Gardner wrote:
    I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few
    more hacks, I think it all looks good.

    I need some help to make it professional.

    It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few
    hours... =)
    If you can get it to compile (just edit the Makefile to make it point to
    the right place...) try this with Vim 6.0:

    $ gvim --servername TEST
    $ python
    import vim
    vim.list()
    ['TEST']
    vim.send('TEST', 'iHello World!<ESC>')
    You should see the string "Hello World!" neatly typed into the newly opened
    vim window!!!

    Sorry, X11 only right now...

    Jonathan

    [ Note: This was cross-posted to vim-dev and python-list so I can go to bed
    sooner... ]
  • Tim Hammerquist at Nov 14, 2001 at 2:44 am
    simonb at webone.com.au <simonb at webone.com.au> graced us by uttering:
    [ snip ]
    If you can get it to compile (just edit the Makefile to make it point to
    the right place...) try this with Vim 6.0:

    $ gvim --servername TEST
    $ python
    import vim
    vim.list()
    ['TEST']
    vim.send('TEST', 'iHello World!<ESC>')
    You should see the string "Hello World!" neatly typed into the newly opened
    vim window!!!
    [ snip ]

    Jonathan Gardner wrote:
    Well this sounds interesting...

    i compiled vim60 with
    CONF_OPT_PYTHON = --enable-pythoninterp
    in the Makefile,
    but "import vim" fails.
    what next?

    Simon Burton
    It seems Simon didn't post the code to clpy, but only to vim-dev.
    Searching the vim-dev archives, the code is indeed there It is a
    python module (named vim.py) that may be loaded from outside of vim
    (or rather gvim, at the moment).

    The following worked perfectly on my box:

    $ gvim
    $ python
    Python 2.1 (#2, Oct 8 2001, 20:43:58)
    [GCC 2.95.3 19991030 (prerelease)] on linux2
    Type "copyright", "credits" or "license" for more information.
    import vim, os
    vim.list()
    ['GVIM']
    vim.send('GVIM', '<ESC>:version<CR>')
    vim.send('GVIM', '<CR>')
    os.system('gvim')
    for i in vim.list():
    ... vim.send(i, '<ESC>:version<CR>')
    ... raw_input("Press <CR> to continue...");
    ... vim.send(i, '<CR>')
    ...
    Press <CR> to continue...
    ''
    Press <CR> to continue...
    ''
    vim.list()
    ['GVIM', 'GVIM2']
    vim.send('GVIM2', ':q!<CR>')
    ^D
    (can't close 'GVIM'...it's got my post!)

    Congratulations, Simon!

    Tim Hammerquist
    --
    If you had two people with a motive, and one of them
    was alive, who would you arrest?
    -- Inspector Boot, "Theater of Blood"
  • Andrei Kulakov at Nov 14, 2001 at 2:36 am

    On Tue, 13 Nov 2001 02:00:26 +0900, Jonathan Gardner wrote:
    I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few
    more hacks, I think it all looks good.

    I need some help to make it professional.

    It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few
    hours... =)
    If you can get it to compile (just edit the Makefile to make it point to
    the right place...) try this with Vim 6.0:

    $ gvim --servername TEST
    $ python
    import vim
    vim.list()
    ['TEST']
    vim.send('TEST', 'iHello World!<ESC>')
    You should see the string "Hello World!" neatly typed into the newly opened
    vim window!!!

    Sorry, X11 only right now...

    Jonathan

    [ Note: This was cross-posted to vim-dev and python-list so I can go to bed
    sooner... ]
    I'm sorry if this is a dumb question, but what's the purpose of this?


    --
    Cymbaline: intelligent learning mp3 player - python, linux, console.
    get it at: cy.silmarill.org
  • Tim Hammerquist at Nov 14, 2001 at 2:50 am
    Andrei Kulakov <sill at optonline.net> graced us by uttering:
    [ snip ]
    $ gvim --servername TEST
    $ python
    import vim
    vim.list()
    ['TEST']
    vim.send('TEST', 'iHello World!<ESC>')
    You should see the string "Hello World!" neatly typed into the newly opened
    vim window!!!
    I'm sorry if this is a dumb question, but what's the purpose of this?
    Jonathan wrote an extension module for Python that can access each
    instance of gvim on an X display from _outside_ of vim.

    Vim can also be compiled to use Python and/or Perl as an internal
    scripting language, and the Python engine has a builtin module called
    'vim' that grants access to vim internals (buffer lists, lines of
    buffers, etc.) As this module is useful but unavailable outside of vim,
    Jonathan wrote his own.

    Or did I misunderstand your question?

    Tim Hammerquist
    --
    No violence, gentlemen -- no violence, I beg of you! Consider the furniture!
    -- Sherlock Holmes
  • Andrei Kulakov at Nov 14, 2001 at 6:00 am

    On Wed, 14 Nov 2001 02:50:33 GMT, Tim Hammerquist wrote:
    Andrei Kulakov <sill at optonline.net> graced us by uttering:
    [ snip ]
    $ gvim --servername TEST
    $ python
    import vim
    vim.list()
    ['TEST']
    vim.send('TEST', 'iHello World!<ESC>')
    You should see the string "Hello World!" neatly typed into the newly opened
    vim window!!!
    I'm sorry if this is a dumb question, but what's the purpose of this?
    Jonathan wrote an extension module for Python that can access each
    instance of gvim on an X display from _outside_ of vim.

    Vim can also be compiled to use Python and/or Perl as an internal
    scripting language, and the Python engine has a builtin module called
    'vim' that grants access to vim internals (buffer lists, lines of
    buffers, etc.) As this module is useful but unavailable outside of vim,
    Jonathan wrote his own.

    Or did I misunderstand your question?
    Oh, I understand what it *does*. I just don't understand what is the
    purpose, i.e. what would be a useful application of this module?

    I'm asking because I love vim and I used python vim module and if
    someone finds this thing useful, I might too..

    Tim Hammerquist

    --
    Cymbaline: intelligent learning mp3 player - python, linux, console.
    get it at: cy.silmarill.org
  • Tim Hammerquist at Nov 15, 2001 at 1:10 am

    Andrei Kulakov <sill at optonline.net> graced us by uttering:
    I'm sorry if this is a dumb question, but what's the purpose of this?
    Andrei Kulakov <sill at optonline.net> graced us again by uttering:
    I just don't understand what is the
    purpose, i.e. what would be a useful application of this module?

    I'm asking because I love vim and I used python vim module and if
    someone finds this thing useful, I might too..
    I can't seem to say what I mean, so let the author speak for himself:

    In correspondence, Tim Hammerquist wrote:
    Jonathan Gardner wrote:
    The main idea that drove me to this insanity was getting a way to edit
    files with vim and also to incorporate some kind of IDE with it. For
    instance, Wouldn't It Be Great If (TM): You could edit Python classes
    outside of the script, and see your changes immediately inserted into the
    file? WIBGI you could connect your debugger (which cannot run inside Vim)
    to Vim and have it highlight lines and show error messages? WIBGI you could
    actually CHOOSE which editor you used for all the day-to-day stuff? This is
    all the first step towards it.

    All that I implemented at this point is the code to allow you to send
    messages to a vim session. In the future, I will implement some code to get
    the responses. And then maybe I'll be able to build an interface to allow
    you to work directly with buffers, etc...

    Jonathan
    WIBGI is one of major driving forces of software development (as opposed
    to a suit's request..."It would be great if you could...for me.
    Thanks.")

    This will also allow Vim to offer the flexibility Emacs loves to claim,
    but without the monolithic size. Yay! =)

    Tim Hammerquist
    --
    All mail clients suck. This one just sucks less.
    -- Michael Elkins on mutt
  • Brian Sturk at Dec 11, 2001 at 3:32 am

    On Thu, 15 Nov 2001 01:10:13 GMT, Tim Hammerquist wrote:
    Andrei Kulakov <sill at optonline.net> graced us by uttering:
    I'm sorry if this is a dumb question, but what's the purpose of this?
    Andrei Kulakov <sill at optonline.net> graced us again by uttering:
    I just don't understand what is the
    purpose, i.e. what would be a useful application of this module?

    I'm asking because I love vim and I used python vim module and if
    someone finds this thing useful, I might too..
    Check out my terminal buffer python script for vim. I find it
    useful. :)

    http://www.nh.ultranet.com/~bsturk/vim.html

    Having just started programming with python, I find it easier to
    write scripts using it than vim's built in scripting language.
    I can't seem to say what I mean, so let the author speak for himself:

    In correspondence, Tim Hammerquist wrote:
    Jonathan Gardner wrote:
    The main idea that drove me to this insanity was getting a way to edit
    files with vim and also to incorporate some kind of IDE with it. For
    instance, Wouldn't It Be Great If (TM): You could edit Python classes
    outside of the script, and see your changes immediately inserted into the
    file? WIBGI you could connect your debugger (which cannot run inside Vim)
    to Vim and have it highlight lines and show error messages? WIBGI you could
    actually CHOOSE which editor you used for all the day-to-day stuff? This is
    all the first step towards it.
    I'll be working on the above. At least for C and gdb. What does python
    use for a debugger? The script mentioned above will have hooks put in it
    for actions on the read/write ends to trigger actions in vim. Using the
    new glyph code you could possibly single step code all from within vim.
    I haven't tested any of this out, but I think it's possible.
    All that I implemented at this point is the code to allow you to send
    messages to a vim session. In the future, I will implement some code to get
    the responses. And then maybe I'll be able to build an interface to allow
    you to work directly with buffers, etc...

    Jonathan
    WIBGI is one of major driving forces of software development (as opposed
    to a suit's request..."It would be great if you could...for me.
    Thanks.")

    This will also allow Vim to offer the flexibility Emacs loves to claim,
    but without the monolithic size. Yay! =)
    And that's having the best of both worlds.

    --
    .-----------------------------------------------------,-------.
    Brian M. Sturk - http://www.nh.ultranet.com/~bsturk \ C/C++ | .> )\,^a__
    --------------------------| bsturk at nh.ultranet.com | Java | ( _ _)/ /-." ~
    http://www.telengard.com `---------------------------`------| `( )_ )/
    Telengard Technologies Inc. - NT/*nix UI & device drivers | _<_s_<_s
    '-------------------------------------------------------------'
  • Kevin Dahlhausen at Dec 11, 2001 at 5:43 pm
    It looks sounds great. I'm having some trouble running it under NT
    4.0, SP 6, Gvim 6.0u though. It gives this error when :pyf vimsh.py

    line 181, in read
    r,w,e = select.select([self.outd], [], [], self.delay )
    select.error: (2, 'No such file or directory')


    Any ideas?
  • Brian Sturk at Dec 12, 2001 at 6:04 am

    On 11 Dec 2001 09:43:20 -0800, Kevin Dahlhausen wrote:

    http://www.nh.ultranet.com/~bsturk/vim.html
    It looks sounds great. I'm having some trouble running it under NT
    4.0, SP 6, Gvim 6.0u though. It gives this error when :pyf vimsh.py

    line 181, in read
    r,w,e = select.select([self.outd], [], [], self.delay )
    select.error: (2, 'No such file or directory')


    Any ideas?
    Yeah, in the notes in the script I mentioned select() only works w/ sockets.
    Hopefully tonight I'll be uploading a new version which works
    much better under Windows, or better put, actually works under Windows.

    :)

    --
    .-----------------------------------------------------,-------.
    Brian M. Sturk - http://www.nh.ultranet.com/~bsturk \ C/C++ | .> )\,^a__
    --------------------------| bsturk at nh.ultranet.com | Java | ( _ _)/ /-." ~
    http://www.telengard.com `---------------------------`------| `( )_ )/
    Telengard Technologies Inc. - NT/*nix UI & device drivers | _<_s_<_s
    '-------------------------------------------------------------'
  • Jonathan Gardner at Dec 12, 2001 at 1:24 am

    On Tuesday 11 December 2001 12:32 pm, Brian Sturk wrote:
    Check out my terminal buffer python script for vim. I find it
    useful. :)

    http://www.nh.ultranet.com/~bsturk/vim.html
    Make sure this gets on the vim.sourceforge.net site or they know to link to
    you. It is pretty cool.

    Jonathan

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedNov 12, '01 at 5:00p
activeDec 12, '01 at 6:04a
posts15
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase