http://www.perlmonks.org?node_id=41736
Category: Fun Stuff
Author/Contact Info dxt2431@yahoo.com
Description: I am writing VI in Perl (vip), and I wanted to gather some comments. I post my code to the web site every 4-5 revisions. vip is almost usable now. Thanks for your input, people.
Replies are listed 'Best First'.
RE: VI in Perl
by clemburg (Curate) on Nov 15, 2000 at 17:43 UTC

    Hm. I admire your courage, and hope you do this for educational purposes only. You maybe want to register your effort with the Perl Power Tools project, they don't have the vi command in stock yet.

    As a feedback on your program, on my machine (linux) it produces a lot of garbage like this (running inside an ssh terminal):

    > perl vip.pl --> v_screen::new --> v_screen::init --> v_window::new --> v_window::init --> v_file::new --> v_screen::execute ~ --> v_window::command ~ --> v_file::command ~ --> v_win +dow::draw ~ + - -> v_window::position ~ --> v_file::position ~ --> v_file::topline ~ --> v_wind +ow::exl_to p ~--> v_window::_win_size ~ --> v_file::get_lines ~ Use of uninitialized valu +e at vip.p l line 475. ~ Use of uninitialized value at vip.pl line 475. ~ [ ... snip ... ] Use of uninitialized value at vip.pl line 2791. SIGINT handler "i +gnore" not defined. SIGINT handler "ignore" not defined. SIGINT handler "ignore" n +ot defined . SIGINT handler "ignore" not defined. Quit

    Maybe you can give more detailed instructions on how to build, run, test it, etc, for those interested.

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

      Oh, of course. I print debugging information to STDERR, so run it like this: $ ./vip file.txt 2> log or $ ./vip file.txt 2> /dev/null - Dmitri.
RE: VI in Perl
by Dominus (Parson) on Nov 16, 2000 at 01:36 UTC
    This is a really impressive project. I was just thinking yesterday that if someone wrote an editor in Perl, and designed the internals properly, it would be trivial to use Perl as an extension language for it. Are you planning to do something like that?
      There is a project (called Perlmacs) to make add support for Perl embedded in Emacs. You can find details about it here.

      When I first heard about it, I thought it was the Holy Grail I have been searching for, but... like Emacs, as much as I love the extensibility, it just seems clunky and resistant to use.

      I'm still looking for a 'really good editor'.

      --Glenn

        There's this editor that's not emacs and you can embed Perl in it already =)

        As if I needed *reasons* for being on one side or the other =)

      It will hopefully be extensible... right now

      :s/foo/bar/g

      is implemented internally using eval(). There is also a way to specify perl code from command line, i.e.:

      :.,+10 {$_=reverse}

      to reverse 11 lines.

      This project of mine is far from complete, and the code is messy and unoptimized. However I hope that it will be a good learning experience (it already has), and maybe in a couple of weeks I will use vip to develop vip. :)

      Next big things on my list are recovery and a cache to optimize the linked list access (right now it is pretty slow, look for /_get_reference_to_number/ in v_list.

      - Dmitri.

        When I was looking through the code, I found myself wondering why you had used linked lists at all, instead of Perl arrays. Wouldn't that have been faster and simpler?

RE: VI in Perl
by dmitri (Priest) on Nov 15, 2000 at 14:21 UTC
    downvoting is fine, how about comments?
Re: VI in Perl
by ambrus (Abbot) on Oct 04, 2003 at 20:31 UTC
    I think that vip is not a good name, as there is a vi-emulator for emacs named vip, altough it is now superseded by viper= VI Plan for Emacs Rescue. There is an 1991 entry IOCCC that is a vi-style editor.
      Thanks for the comment :) I've abandoned the project (which never became anything more than school project) a couple of years ago.
        Awe come on dude, you have to put more effort into it than that :-) When you post things to the net they live forever:

        Posted By: perlguy0
        Date: 2001-05-15 23:14
        Summary: The very first release.
        This is the very first release of VI in Perl.
        Let there be more like it.
        Let Larry start using vip as THE editor.
        Let everyone become interested in it and help with the coding.

        The hero is born, and I will nurture it and I will not fail.

        Amen.