vi "power tools" for Perl coding?

Discussion in 'Perl Misc' started by J Krugman, Feb 14, 2005.

  1. J Krugman

    J Krugman Guest

    Let me preface this post by stressing that my intent is NOT to
    start a religious vi-vs-emacs flame fest.

    I have noticed that vi is *particularly* popular among Perl
    programmers, and (as an Emacs enthusiast) I wonder why. I have
    edited Perl code with plain ol' vim, and found the experience much
    less pleasant than editing Perl with Emacs's cperl mode, but I'm
    sure that, in my ignorance, I was not taking advantage of the vi
    power tools for Perl coding. So my question really boils down to
    what should I do to get a taste of the joys of coding (and debugging?)
    Perl with vi?

    TIA,

    jill

    P.S. Yes, I have read perldoc -q editor

    P.S.2 What motivated this question was my learning about the handy
    little vi sequence

    :!perl -cW

    for checking the syntax on a buffer of Perl code. The equivalent
    in emacs is a bit more long-winded:

    C-x h
    M-| perl -cW

    So I decided to add the following to my .emacs file (probably
    re-inventing a thoroughly invented wheel):

    (defun check-perl (&optional arg)
    "Checks the Perl syntax in current buffer.
    If the mark is set and either it is active or transient-mark-mode
    is nil, the current region is checked. Otherwise the entire
    buffer is checked. With a numeric argument, the check is made under
    the strict pragma."
    (interactive "P")
    (let (start end (strict ""))
    (if (and (mark)
    (or mark-active
    (not transient-mark-mode)))
    (progn (setq start (mark ))
    (setq end (point)))
    (progn (setq start (point-min))
    (setq end (point-max)))
    )
    (if arg (setq strict "-Mstrict "))
    (shell-command-on-region
    start end (concat "perl " strict "-Mdiagnostics -cW "))))

    ;; The following binds the F12 key to the check-perl command in
    ;; the cperl mode
    (add-hook 'cperl-mode-hook (lambda ()
    (local-set-key [(f12)] 'check-perl)
    ))
    --
    To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
    J Krugman, Feb 14, 2005
    #1
    1. Advertising

  2. J Krugman

    Guest

    J Krugman wrote:
    > Let me preface this post by stressing that my intent is NOT to
    > start a religious vi-vs-emacs flame fest.
    >
    > I have noticed that vi is *particularly* popular among Perl
    > programmers, and (as an Emacs enthusiast) I wonder why. I have
    > edited Perl code with plain ol' vim, and found the experience much
    > less pleasant than editing Perl with Emacs's cperl mode, but I'm
    > sure that, in my ignorance, I was not taking advantage of the vi
    > power tools for Perl coding. So my question really boils down to
    > what should I do to get a taste of the joys of coding (and

    debugging?)
    > Perl with vi?
    >
    > TIA,
    >
    > jill
    >


    I like vi because I have invested some time in learning it and emacs
    seems harder to use to me. I don't use any advanced features really.
    Someday, I'll get around to playing with emacs. These editors are like
    musical instruments. To be useful, your fingers have to have their own
    learned intelligence in picking out the commands without any concious
    thought. It takes a lot of time and practice to gain that proficiency,
    unlike your typical wordpad-type editor.

    Asking a vi user like me to take up emacs is like asking a sax player
    to take up piano. I like playing my instrument because I know how to
    play it, even if you think yours is better.

    wana
    , Feb 14, 2005
    #2
    1. Advertising

  3. J Krugman wrote :
    >
    >
    >
    > Let me preface this post by stressing that my intent is NOT to
    > start a religious vi-vs-emacs flame fest.
    >
    > I have noticed that vi is *particularly* popular among Perl
    > programmers, and (as an Emacs enthusiast) I wonder why. I have
    > edited Perl code with plain ol' vim, and found the experience much
    > less pleasant than editing Perl with Emacs's cperl mode, but I'm
    > sure that, in my ignorance, I was not taking advantage of the vi
    > power tools for Perl coding. So my question really boils down to
    > what should I do to get a taste of the joys of coding (and debugging?)
    > Perl with vi?


    I have not used emacs enough to really be able to compare those two.
    I would not even use vi nowadays but vim.
    There are so many "powerfeatures" that one could write a book on it.

    One I dicovered these days (I guess emacs can do this, too, however) is
    directly editing files on a ftp server.
    vim ftp://myserver.domain.tld/dir/file.pl
    This is very useful if only some small changes have to be made.

    Also you can compile vim to support perl directly within command mode.
    To me, vim is something like the swiss army knife of text editing, but I
    am sure emacs can also be that.

    Finally a little cartoon about vi vs. emacs ;-)
    http://www.io.com/~dierdorf/vi-emacs2.jpg

    Regards
    Martin

    --
    perl -e 'print 7.74.117.115.116.11.32.13.97.110.111.116.104.101.114.11
    ..32.13.112.101.114.108.11.32.13.104.97.99.107.101.114.10.7'
    Martin Kissner, Feb 14, 2005
    #3
  4. Also sprach Abigail:

    > J Krugman () wrote on MMMMCLXXXV September
    > MCMXCIII in <URL:news:cup47s$ldl$>:


    > [] So I decided to add the following to my .emacs file (probably
    > [] re-inventing a thoroughly invented wheel):
    >
    > [ 19 line macro ]
    >
    > A similar macro for my editor:
    >
    > 3 store-macro
    > save-file
    > shell-command &cat "perl -c " $cfilname
    > ~endm


    Ah, that is not going to win you a vim golfing contest. For checking the
    syntax of a script or running it, I have in my vimrc:

    map ü :!perl -w % <CR>
    map ö :!perl -wc % <CR>

    Tassilo
    --
    use bigint;
    $n=71423350343770280161397026330337371139054411854220053437565440;
    $m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
    Tassilo v. Parseval, Feb 14, 2005
    #4
  5. J Krugman

    Kim Schulz Guest

    On Mon, 14 Feb 2005 03:00:12 +0000 (UTC)
    J Krugman <> wrote:

    >
    >
    >
    > Let me preface this post by stressing that my intent is NOT to
    > start a religious vi-vs-emacs flame fest.
    >
    > I have noticed that vi is *particularly* popular among Perl
    > programmers, and (as an Emacs enthusiast) I wonder why. I have
    > edited Perl code with plain ol' vim, and found the experience much
    > less pleasant than editing Perl with Emacs's cperl mode, but I'm
    > sure that, in my ignorance, I was not taking advantage of the vi
    > power tools for Perl coding. So my question really boils down to
    > what should I do to get a taste of the joys of coding (and debugging?)
    > Perl with vi?
    >


    Besides the simple and nice stuff like indenting, syntax coloring,
    autocompletion (tab-completion of known/used words) and folding I use
    stuff like:

    tag/Function/method/class/define list (tree in sepetate split buffer):
    - http://www.vim.org/scripts/script.php?script_id=483
    - http://www.vim.org/scripts/script.php?script_id=273
    Selection evaluation:
    - http://www.vim.org/scripts/script.php?script_id=889
    Perl "Compiler":
    - http://www.vim.org/scripts/script.php?script_id=56
    Debugger integration:
    - http://www.vim.org/scripts/script.php?script_id=663
    Syntax checker:
    - http://www.vim.org/scripts/script.php?script_id=1096
    Execute perl:
    - http://www.vim.org/scripts/script.php?script_id=281
    Automate module generation:
    http://www.vim.org/scripts/script.php?script_id=466

    just to mention a few.

    --
    Kim Schulz | Want to know more about The Fundanemt CMS. Join the
    Geek by nature | users and developers at linuxforum 2005.
    schulz.dk | http://www.linuxforum.dk
    Kim Schulz, Feb 14, 2005
    #5
  6. J Krugman

    Anno Siegel Guest

    J Krugman <> wrote in comp.lang.perl.misc:
    >
    >
    >
    > Let me preface this post by stressing that my intent is NOT to
    > start a religious vi-vs-emacs flame fest.
    >
    > I have noticed that vi is *particularly* popular among Perl
    > programmers, and (as an Emacs enthusiast) I wonder why. I have
    > edited Perl code with plain ol' vim, and found the experience much
    > less pleasant than editing Perl with Emacs's cperl mode, but I'm
    > sure that, in my ignorance, I was not taking advantage of the vi
    > power tools for Perl coding. So my question really boils down to
    > what should I do to get a taste of the joys of coding (and debugging?)
    > Perl with vi?


    Let me add the CPAN module Vi::QuickFix to the list of suggestions.
    It gives you direct access (in Vim) to the places in the source the
    last Perl run has complained about. This is the one worth-while feature
    of IDEs you don't get when the editor and the compiler run independently.

    Anno
    Anno Siegel, Feb 14, 2005
    #6
  7. J Krugman

    Sam Holden Guest

    On 14 Feb 2005 22:54:54 GMT, Abigail <> wrote:
    > J Krugman () wrote on MMMMCLXXXV September
    > MCMXCIII in <URL:news:cup47s$ldl$>:
    >
    > But who cares? If you like emacs, and its cperl mode works for you,
    > then keep using that.
    >
    >
    > [] So I decided to add the following to my .emacs file (probably
    > [] re-inventing a thoroughly invented wheel):
    >
    > [ 19 line macro ]
    >
    > A similar macro for my editor:
    >
    > 3 store-macro
    > save-file
    > shell-command &cat "perl -c " $cfilname
    > ~endm


    Can I play editor wars to? :)

    #!/bin/sh
    Put
    wperl -c "$w"

    >
    > [] (add-hook 'cperl-mode-hook (lambda ()
    > [] (local-set-key [(f12)] 'check-perl)
    > [] ))
    >
    >
    > bind-key execute-macro-3 ^A-c


    My editor doesn't do that, you just put the name of the file somewhere.

    --
    Sam Holden
    Sam Holden, Feb 15, 2005
    #7
  8. J Krugman

    jopa Guest

    I use these perl specific lines in my vimrc.

    let perl_want_scope_in_variables=1
    let perl_extended_vars=1
    let perl_include_pod=1

    Anyone know of other perl specific .vimrc options?

    I also use things like:

    iab _oIN open (IN, "") \|\| die "Pukeonfile : $!\n";<CR>@array =
    <IN>;<CR>close IN;

    Which lets me type "_oIN" then hit enter for an open file block.

    Jopa
    ~~~~`
    jopa, Feb 15, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Micah

    *Python* Power Tools

    Micah, Jun 21, 2005, in forum: Python
    Replies:
    4
    Views:
    456
    Ville Vainio
    Jun 22, 2005
  2. calmar
    Replies:
    11
    Views:
    779
    calmar
    Feb 21, 2006
  3. www
    Replies:
    1
    Views:
    284
  4. www
    Replies:
    1
    Views:
    281
  5. www
    Replies:
    2
    Views:
    480
    Kai Schwebke
    Mar 10, 2007
Loading...

Share This Page