Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: How to write out a Perl script and run it in as few keystrokes as possible.

by MrSnrub (Sexton)
on Sep 24, 2012 at 23:20 UTC ( #995454=note: print w/replies, xml ) Need Help??

in reply to Re: How to write out a Perl script and run it in as few keystrokes as possible.
in thread How to write out a Perl script and run it in as few keystrokes as possible.

I would think that would actually increase the number of keystrokes needed by one:

Original Process

(UP)vim (2 keystrokes)
(make changes) (0 keystrokes)
:wq(ENTER) (4 keystrokes) *
(UP)(UP)perl -Wall (3 keystrokes)
GOTO Start

Total: 8 keystrokes

Two-Window Process

(edit .pl file in vim, window1) (0 keystrokes)
:w(ENTER) (3 keystrokes) *
Alt-Tab to window2 (2 keystrokes)
(UP)perl -Wall (2 keystrokes)
Alt-Tab back to window1 (2 keystrokes)
GOTO Start

Total: 9 keystrokes

* : only counts as one keystroke because in my .vimrc I have ; mapped to : and vice-versa so I don't need to press the Shift key

Replies are listed 'Best First'.
Re^3: How to write out a Perl script and run it in as few keystrokes as possible.
by tinita (Parson) on Sep 24, 2012 at 23:28 UTC
    the first process can even be shortened by using ZZ instead of :wq and enter.
    but one advantage of the second is, you still have the vim history and can undo the recent changes easily. another is, you can still see the output of your script when continuing with editing.
Re^3: How to write out a Perl script and run it in as few keystrokes as possible.
by dsheroh (Prior) on Sep 25, 2012 at 09:34 UTC
    Enable sloppy focus/focus-follows-mouse and both alt-tab instances go away, reducing it to 5 keystrokes - just drift your mouse pointer over the other terminal window. (And, yes, I'm pretty sure both Windows and OSX have options/plugins/tweaks that let you use sloppy focus. It's not an X-only thing.)

    Even without that, you forgot to account for needing to go back twice in command history to return to editing the source after running it. Include that forgotten "(UP)", and it's a tie at 9 and 9.

    More importantly, as already mentioned, keeping your vi(m) session open lets you keep your undo history, which can be far more valuable than shaving off a keystroke here and there.

    Using multiple windows/tabs also generalizes nicely to working with multiple source files (you do organize your code into modules rather than making it all one huge file, don't you?), since you can view and switch between the different source files trivially rather than having to try to find the correct file in your command history.

    (Am I the only one who thinks this entire quest is a bit silly, though? I know that the primary bottleneck in my coding is not the number of keystrokes I spend in the shell... Not even close...)

Re^3: How to write out a Perl script and run it in as few keystrokes as possible.
by johngg (Abbot) on Sep 25, 2012 at 10:11 UTC

    I think that your single window method is also going to be 9 keystrokes because you will need 2 up-arrows to get back to vim once you have run your script.

    When given the choice I prefer to use a GUI editor, nedit, and I have set up my window manager so that focus follows the mouse without the need to click in a window. I also use emacs-style command history navigation as I was an Emacs user on Pr1mos long before I ever saw vi so am more familiar with it. My process is as follows:-

    • Start:
    • Edit script with nedit - (0 keystrokes)
    • Ctrl-S to save (2 keystrokes)
    • Move mouse over xterm window (1 wrist twitch)
    • Ctrl-P then Enter to re-run script (3 keystrokes)
    • Move mouse back to nedit window (1 wrist twitch)
    • GOTO Start

    I make that 5 keystrokes and 2 wrist twitches.



      nedit used to be my text editor of choice. I now prefer SciTE; it has more reliable Perl syntax highlighting (I often found nedit couldn't find the end of a string or regexp) and an integrated panel for displaying shell output, so if I'm editing a Perl script, I just need to save it and hit F5 to show the output at the bottom of my editing screen.

      My only slight gripe is that the regular expression engine used by SciTE's search and replace is not quite as advanced as nedit's. But I can always copy and paste into a nedit window for advanced search and replace. (Or just run Perl or sed over the file.)

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995454]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2018-07-19 08:16 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (404 votes). Check out past polls.