Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Favorite Text Editor?

by sierrathedog04 (Hermit)
on May 22, 2001 at 21:15 UTC ( [id://82304]=note: print w/replies, xml ) Need Help??


in reply to Favorite Text Editor?

If I may add to Rhandom's question about vi, here is my related one: I use either the vim or vile variants of vi to write Perl scripts. I would love from inside the vi editor to be able to run my perl programs and see my output and errors (if any), possibly in separate windows.

But I don't know how to run my Perl scripts from inside of vi. Sometimes I fire up a shell inside vi and run my Perl script inside the shell, but that is a lot of extra typing.

Back when I used to use the Borland C++ editor I was able to run Perl scripts from inside the editor. There must be away to do so with vi. If anyone knows how then please clue me in.

Update: It is in fact easy to run a perl script while vi is editing it. You simply type the following EX editor command at the colon prompt:

!perl %
If you start your perl program off with the shebang command, then you can also use the following command instead:
!./%

Replies are listed 'Best First'.
Re: Re: Favorite Text Editor?
by bwana147 (Pilgrim) on May 23, 2001 at 17:20 UTC

    In the same range, I'm rather fond of the filtering feature of vim (actually, I think it's a feature of all "standard" vi's).

    If you prefix the ! with a range (i.e. "%" for the whole buffer, or ".,147" for current line thru line 147, or "'a,'b" for marker a thru marker b, etc.), vi will pipe the given range into the external command that follows the bang, and replace it with the output of the same command.

    Very useful for one-liners, IMHO. Example: you're editing an SQL file with zillions of INSERT statements, and want to insert a COMMIT every 500 lines, lest the rollback segments chokes under the load:

    :%!perl -ple "print 'COMMIT;' unless $.\%500"

    You need to escape the modulo operator, lest vi interpolates into the current buffer name

    The down side is that you don't see error messages. Unless maybe you say 2>&1 (haven't tried that yet, though

    --bwana147

Re: Re: Favorite Text Editor?
by alfie (Pilgrim) on May 23, 2001 at 18:05 UTC
    You might find the :make feature of vim very useful: You can set makeprg to "perl\ -cw\ %" and use afterwards :make to check the program. This aproach offers you some nice features:
    • It's easier to type
    • You get the error-messages in a special buffer and can step through it. Read about this feature in :help quickfix
    Another real good feature, btw :)
    --
    use signature; signature(" So long\nAlfie");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://82304]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-24 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found