Loading ...
Sorry, an error occurred while loading the content.

Extending Scripting By Using Perl, Python, Tcl, and Ruby

Expand Messages
  • The Vim Man
    I was wondering why there are no posts of some of the more interesting scripts made in any of the above languages to see how good a combination you can make
    Message 1 of 5 , Sep 1, 2002
    • 0 Attachment
      I was wondering why there are no posts of some of the more interesting
      scripts made in any of the above languages to see how good a
      combination you can make using Vim with these scripting languages. As
      far as I know, all the scripts currently on vim.sourceforge.net just
      use Vim's own scripting language. How powerful can you make Vim (what
      funky things can you do) when you combine Vim with one of the above
      scripting languages? Thanks for your time...--
      The fastest email on the Internet!
      http://fastmail.fm - Choose from over 50 domains or use your own
    • Colin Keith
      ... *urm* They are there. Look through the newsgroups might be a little more revealing. I konw I ve certainly posted a few suggestions to questions using Perl
      Message 2 of 5 , Sep 1, 2002
      • 0 Attachment
        On Sun, Sep 01, 2002 at 04:54:51PM +0000, The Vim Man wrote:
        > far as I know, all the scripts currently on vim.sourceforge.net just
        > use Vim's own scripting language. How powerful can you make Vim (what
        > funky things can you do) when you combine Vim with one of the above
        > scripting languages? Thanks for your time...--

        *urm* They are there. Look through the newsgroups might be a little more
        revealing. I konw I've certainly posted a few suggestions to questions
        using Perl (althought not lately because I've been too busy). You can do
        anything with the interpreters embedding into Vim that you can do with them
        stand alone. So if you know how to use Perl (python, ruby, etc.) you can
        use it from in Vim. What makes the embedded interpreter better than using
        the same language externally is the fact that you can updating your file
        and notify the user without relying on awkward calls to external programs
        (although Vim handles those beautifully as well). The trick is to find a
        use for these extensions, but since Vim is a text editor it can be
        limiting. Whilst you may use Perl to parse your system logs nightly, but
        you wouldn't write an interface for doing it from Vim because you don't use
        Vim like that.


        You might write a hmm...

        * HTML beautifier perhaps - so when you open a .html file you have a
        BufPreRead autocmd that passes the text through HTML::TokeParser.

        * You might want to be able to edit a .db file, so your preprocessor uses
        the Perl tie() function, and DB_File to tie an array to the db file.
        Each entry in the array is then turned into a line in your file. When
        you save it another autocmd reverses the process, allowing you to edit
        your Berkeley DB files seamlessly.

        * You could extend this idea to allow you to edit /var/log/wtmp so you
        could "logout" people.s

        * On windows you might want to use Win32::TieRegistry to access the
        registry so you could:

        :e registry://HKCR/.txt

        You could then set the filetype association for .txt files to
        vim_auto_file. When you've changed it, save and it updates the registry -
        (WARNING! Don't muck about with your registry if you don't know _exactly_
        what you're doing)

        If you're looking for examples of situations, I can remember posting an
        answer to "how to edit a file without changing its mtime" and using Perl to
        sort in some specific fashion. Check the mailing list archives on yahoo
        groups, just don't expect thousands of examples as extensions using Perl
        etc. tend to be for specific situations.

        Hope that helps a little.

        Col.
      • Tim Hammerquist
        ... Using supplementary scripting languages does not seem to be a frequent topic on the ML (or on comp.editors, for that matter), but it does get discussed.
        Message 3 of 5 , Sep 1, 2002
        • 0 Attachment
          The Vim Man wrote:
          > I was wondering why there are no posts of some of the more
          > interesting scripts made in any of the above languages to see
          > how good a combination you can make using Vim with these
          > scripting languages.

          Using supplementary scripting languages does not seem to be a
          frequent topic on the ML (or on comp.editors, for that matter),
          but it does get discussed.

          > As far as I know, all the scripts currently on
          > vim.sourceforge.net just use Vim's own scripting language.

          Most use Vim's lang, yes, but there are a few projects that use
          the Perl or Python interface. I know there is at least one shell
          emulater for Vim that uses Python.

          OTOH, many scripts on vim.sf.net use Vim lang simply because it's
          the only one guaranteed to be available. Perl, Python, Ruby, and
          Tcl interfaces are all optional. Regardless of how cool
          something I wrote in Perl is, it won't do any good to someone
          who doesn't have vim +perl.

          > How powerful can you make Vim (what funky things can you do)
          > when you combine Vim with one of the above scripting languages?

          That said (above), I've been working on a ruby interface project
          for couple weeks. Nothing grand, but it ties Vim to an Xmms
          (*nix mp3 player) session.

          I found a ruby lib that connected to an xmms session, which I
          then loaded into a vim script and wrote a couple wrapper
          functions in Vim to call it with specific keybindings.

          Then I customized the vtreeexplorer.vim to load an mp3 file or
          playlist.

          Then I added an playlist editor buffer based on bufexplorer.vim.

          There are also a couple flourishes in the buffers, such as syntax
          coloring to demark the title, play-time, etc.

          A dedicated [XmmsControl] buffer is in the works at the moment.

          It hasn't been release to the public (on vim.sf.net) yet, and
          requires:

          - Vim +ruby
          - Xmms v1.2.6 or higher <http://www.xmms.org/>
          - XMMS-Ruby 0.1.0 or higher lib for Ruby
          <http://www.pablotron.org/>

          Timmy
          --
          Death is not good. I reject death. I will stay away from trucks today.
          -- Larry Wall in <199909151845.LAA26509@...>
        • Steve Hall
          From: Colin Keith ... This is one of those things proving not everything that *can* be done, *should* be. Colin, you scare me. ;)
          Message 4 of 5 , Sep 17, 2002
          • 0 Attachment
            From: "Colin Keith" <vim@...>
            >
            > http://vim.sourceforge.net/script.php?script_id=418
            >
            > it does read and write from your [Windows] registry.

            This is one of those things proving not everything that *can* be done,
            *should* be. Colin, you scare me. ;) (Nice job though!)


            Steve Hall [ digitect@... ]
          • Michael Brailsford
            ... I wrote this http://vim.sourceforge.net/script.php?script_id=274. It parses your C/C++ structs, typedefs and classes using ruby. It then creates vim
            Message 5 of 5 , Sep 17, 2002
            • 0 Attachment
              > As far as I know, all the scripts currently on vim.sourceforge.net just
              > use Vim's own scripting language. How powerful can you make Vim (what
              > funky things can you do) when you combine Vim with one of the above
              > scripting languages? Thanks for your time...--

              I wrote this http://vim.sourceforge.net/script.php?script_id=274. It
              parses your C/C++ structs, typedefs and classes using ruby. It then
              creates vim highlighting groups for them. I also find myself using ruby
              to write my vim functions becuase ruby's string processing is a lot
              easier to use than vim's builtin functions.

              -Michael
            Your message has been successfully submitted and would be delivered to recipients shortly.