vim & python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian Sturk

    #16
    Re: vim & python

    > > I have a bunch of questions about using python scripting in vim and[color=blue][color=green]
    > > about editing python with vim.[/color]
    >
    > Thanks for all of the answers to the second question, but what about
    > vim scripting with python? I can not find *anything* about it (no
    > docs, books or tutorials)[/color]

    I don't have a tutorial, but I've written a quite large python script for
    vim called vimsh. It might be helpful for you as a reference:

    Download Vim for free. Vim - the ubiquitous text editor. Vim is a highly configurable, keyboard-driven text editor designed to make creating and editing text extremely efficient. It is based on the classic vi editor and comes preinstalled as “vi” on most UNIX systems and macOS.


    hth,
    ~brian

    --
    ..--------------------------------------------------,--------.
    | Brian Sturk - http://users.adelphia.net/~bsturk \ C/C++ |
    |-------------------------. bsturk<AT>adelp hia.net | Python |
    | http://www.telengard.com `------------------------`-------|
    | Telengard Technologies Inc. - NT/*nix UI & device drivers |
    `-----------------------------------------------------------'


    Comment

    • C. Laurence Gonsalves

      #17
      Re: vim &amp; python

      On 4 Mar 2004 18:53:18 -0800, sb <spam_bait101@y ahoo.com> wrote:[color=blue]
      > Thanks, but that is more like a very abbreviated tutorial. Where can I
      > can the real documentation? It seems like the python built into vim is
      > different. For example, doing
      >
      > :py import sys
      > :py dir(sys)
      >
      > produces no output. Odd.[/color]

      The statement 'dir(sys)' doesn't produce any output in Python. What's
      confusing you is that the interactive mode of the python interpreter
      prints the values of expression statements, if the value is not None.
      That's a feature of the interactive mode though, not of Python, the
      language.

      You can verify this for yourself by creating a little script:

      import sys
      dir(sys)

      Copy the above to a file, test.py. The lines should not be indented, of
      course. Then execute 'python test.py' from the shell. Note the lack of
      output.

      In vim, just as in Python scripts, if you want output you need to
      explicitly ask for it. So try the following in vim:

      :py import sys
      :py print dir(sys)

      BTW, the "python built into vim" is really just the normal python
      interpreted, embedded in vim. Everything you know about the Python
      language still holds. The main differences are that it doesn't have the
      same sort of "interactiv e mode" that the python interpreter has, and you
      have access to he vim module. Documentation for the latter can be found
      by executing ':help python-vim'. Yes, the documentation is brief, but it
      is fairly complete, as far as I can tell.

      Comment

      Working...