chorg has asked for the wisdom of the Perl Monks concerning the following question:

Hey there,

I remember reading somewhere (perldoc?) about using vi/vim as an interface to the perl debugger, so I could just debug programs while in sweet sweet vim. I really would like to do this. I know it works like that with emacs, but I use vim and would like the same thing for me. I compiled vim with the built in perl interp - so now how do I debug perl programs without leaving vim (note - I know I can just

:sh perl -d myprog.pl ^D
but I was hoping for a different solution. Any ideas??
_______________________________________________
"Intelligence is a tool used achieve goals, however goals are not always chosen wisely..."

Replies are listed 'Best First'.
Re: vim and perl
by clemburg (Curate) on Dec 08, 2000 at 16:40 UTC

    I have used vim/gvim for a long time. I doubt that you can achieve the level of integration that emacs provides (e.g., stepping you through the source code in sync with the state of the debugger (running the debugger in one window, and the source code in another)).

    From perldoc perldebug :

    (Historically, a similar setup for interacting with vi and the X11 window system had also been available, but at the time of this writing, no debugger support for vi currently exists.)

    Tom Christiansen's .exrc file is available in Unix Power Tools, on page 570-572, snippet 31.09. Source code for the book is available here, and the file you want from in there is "upt2/exrc". But it does not do what you want, I think.

    There is a Perl interface in vim/gvim (go help, search for perl, then follow the documentation pointers), but it accomplishes a different thing: it provides for Perl access to vim editing functions, basically.

    My advice for you would be to go for emacs with the viper (vi emulation) package (I use this all time, and it works great).

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

Re: vim and perl
by t0mas (Priest) on Dec 08, 2000 at 16:40 UTC
    :help design-not VIM IS... NOT *design-not* - Vim is not a shell or an Operating System. You will not be able to +run a shell inside Vim or use it to control a debugger. This should work +the other way around: Use Vim as a component from a shell or in an IDE. A satirical way to say this: "Unlike Emacs, Vim does not attempt to +include everything but the kitchen sink, but some people say that you can cl +ean one with it. ;-)" - Vim is not a fancy GUI editor that tries to look nice at the cost of being less consistent over all platforms. But functional GUI featur +es are welcomed.
    And in perlfaq3:
    Where can I get Perl macros for vi? For a complete version of Tom Christiansen's vi configuration file, se +e http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/toms.exrc +.gz, the standard benchmark file for vi emulators. This runs best with nvi, the current version of vi out of B +erkeley, which incidentally can be built with an embedded Perl interp +reter -- see http://www.perl.com/CPAN/src/misc.
    So I guess your best shoot will be to try nvi and check if it does what you want. Good luck.

    /brother t0mas
Re: vim and perl
by davorg (Chancellor) on Dec 08, 2000 at 16:09 UTC

    I know that Tom Christiansen used to have his vi .exec file in his CPAN directory. That would be a good place to look for stuff like this.

    Unfortunately, I can't seem to find it any more. Tom's directory is at http://www.cpan.org/modules/by-authors/id/T/TO/TOMC/ in case it reappears :).

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: vim and perl
by zigster (Hermit) on Dec 08, 2000 at 16:26 UTC
    Take a look at .../share/vim/vim???/doc/debugger.txt (or from within vim :help debugger) -- quote from this text:

    Currently the only fully integrated debugger/IPE/IDE is Sun's Visual WorkShop Integrated Programming Environment.

    This is from the latest release, checkout Vims home page for more info, but I guess if it is availible it aint in vim by default. I found nothing on perl.com either.
    --

    Zigster
Re: vim and perl
by clintp (Curate) on Dec 09, 2000 at 04:13 UTC
    Well, I've been doing vi and shell for a long time, and the way I do it is (from command mode):

    :!perl -d %
    At least then you drop right to the debugger. Vim will give you a "press return" prompt when your program is done so you don't pop right back into the editor without seeing results.

    If you keep having to go into the debugger, try putting the -d on the #! line and then just:

    :!%
      single most useful thing I found today. thanks - Ben
Re: vim and perl
by repson (Chaplain) on Dec 09, 2000 at 08:25 UTC
    My version of vim vim-perl under debian linux seems to have some rudimentary perl support explained under :help perl but that doesn't seem much use for debugging programs unfortunately. It seems to just be there to allow you to use perl to mutuate the current file.