vi "power tools" for Perl coding?

J

J Krugman

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)
))
 
I

ioneabu

J said:
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
 
M

Martin Kissner

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
 
T

Tassilo v. Parseval

Also sprach Abigail:
J Krugman ([email protected]) wrote on MMMMCLXXXV September
MCMXCIII in <URL:news:[email protected]>:
[] 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
 
K

Kim Schulz

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.
 
A

Anno Siegel

J Krugman said:
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
 
S

Sam Holden

J Krugman ([email protected]) wrote on MMMMCLXXXV September
MCMXCIII in <URL:
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.
 
J

jopa

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
~~~~`
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top