Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Executing script from Vim, annoying...

by mascip (Pilgrim)
on Jul 20, 2012 at 10:59 UTC ( #982789=perlquestion: print w/replies, xml ) Need Help??
mascip has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I've been playing with Vim a bit, lately : .vimrc script for "setting a current file to run", for which to compile, jump to errors, and run. It makes everything faster, and i don't have to switch between Vim and the console all the time.
Perfect! Almost.

When i execute a script from Vim (with :!perl -my/ for example), i hate that as long as the console is opened, i don't have access to my code anymore : Vim is like "frozen". And i have to finish the script execution and close the console, to be able to read and modify my code. And the worst part is when i don't remember what was written on the console, so i have to run the program again just to read something that was already written.

There must be a way around this, probably simple. Any idea?

I'm using Gvim 7.3 on Windows XP.

Replies are listed 'Best First'.
Re: Executing script from Vim, annoying...
by flexvault (Monsignor) on Jul 20, 2012 at 12:38 UTC


    Not knowing your environment, these suggestion are just guesstimates.

    I usually work on *nix, so I opened a XP laptop to verify this will work, and it did. so here goes.

    I opened two command windows (cmd.exe) on the XP, ran Vim in one, and executed the edited Perl script in the other. I could edit with Vim and could interact with the running script by just switching windows.

    For my *nix environments, I run 5 x-windows by default. 3 x-windows are used for Perl programming:

    • #1 for editing the Perl script
    • #2 for execution the Perl script
    • #3 for checking results of the Perl script, such as log files, etc.

    The other 2 windows are used for doing system admin functions as needed. This way I can be interrupted for an emergency, and when things are fixed, I can go back to programming without missing a beat.

    This may not be a solution to your problem, but it may help.

    Good Luck!

    "Well done is better than well said." - Benjamin Franklin

Re: Executing script from Vim, annoying...
by roboticus (Chancellor) on Jul 20, 2012 at 13:15 UTC


    My procedure is quite similar to flexvault's: By running in a different window, I can execute the script with a simple Alt+Tab, UpArrow, Enter after each modification. Quite handy. Another window open for perldoc & such is also quite useful...


    When your only tool is a hammer, all problems look like your thumb.

      It's what i used to do to, and i appreciated to replace

      Alt+Tab - Up - Enter (and Alt+Tab to return to editor)
      by simply
      Especially because before running the script, if there is any compiling error, it automatically opens a new tab and jumps to the first error. And then i have a shortcut to jump to the next compiling error.
      If there is no compiling error it just runs the script.

      So, if there was a way to keep this feature, without this annoying Vim freeze when executing a script, i would love it.

      And i would really like to avoid having to switch to Emacs, right now.

      Idea for a possible solution : if there was a terminal out there, which can be given commands through another terminal's commands, then i could "drive" it from Vim. That would do the trick. Is such a set up possible ?

      There must be a simple way...

Re: Executing script from Vim, annoying...
by aitap (Deacon) on Jul 20, 2012 at 11:58 UTC
    Try using this plugin to run your scripts in a new buffer.
    Sorry if my advice was wrong.

      I installed it, i can type

      :ConqueTerm perl
      and it opens an empty buffer with "perl" written on the bottom. Then, i can write stuff in the buffer but nothing happens.
      If i try instead
      :ConqueTerm perl -e "print 'a'"
      it opens the same buffer, with "perl -e" written at the bottom, and still nothing useful happens.

      Am i doing something wrong ?

      I read the manual, watched videos of people using it, but it just doesn't seem to work on my computer right now.

        Running :ConqueTerm perl -de 42 works for me. Moreover, :ConqueTerm perl -E'say "test"' doesn't work, but :ConqueTerm perl -E'say 1; sleep 1; say 2' works.

        What's more interesting, running :ConqueTerm perl ~/current/ leaves buffer silent, but :ConqueTerm sh -c 'perl ~/current/' works. ( is a script which runs for about a minute while scanning one forum for spam robots)

        Sorry if my advice was wrong.
Re: Executing script from Vim, annoying...
by Anonymous Monk on Jul 20, 2012 at 11:50 UTC
    Switch to emacs?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://982789]
Front-paged by Arunbear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-10-23 11:55 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (279 votes). Check out past polls.