I am setting makeprg to perl % to run my Perl script (if there's a better way, I'm up for that, too), and it works just fine, except that it reproduces the first line of output prefixed with the text "(1 of n)", where n seems to be the total output line count.

I'd like to suppress that, leaving me with just what my Perl script produces. Can I suppress that report line from :make? The .vimrc line that sets up makeprg is:

autocmd FileType perl   :set makeprg=perl\ %
  • you probably want to not use :make but instead map K key to :!perl % (or even :%w!perl) – Naumann Dec 8 '17 at 14:13
  • @Naumann K is usually used for documentation, make for running or compiling programs. I think this is the appropriate way to go. – D. Ben Knoble Dec 8 '17 at 15:54
  • RadlyEel, have you tried using the :compiler command to set the makeprg? Im sure perl has some native support in Vim... do you have filetype plugins enabled? – D. Ben Knoble Dec 8 '17 at 15:55
  • Thanks to both. I didn't like K, but F5 is a commonly used "Run" command in other IDEs, so I used it and that worked perfectly. Using the :compiler command only gives me syntax checking. And there's no user input in this approach, so for interactive scripts I have to use the two-terminal approach. There is a Perl mode in Vim, but I couldn't find what I was looking for. Thanks again. – RadlyEel Dec 9 '17 at 15:15

autocmd BufRead *.pl map <F5> :exe ':silent !perl %'<CR>:redr!<CR>

This defines an autocmd for perl files. If F5 is pressed, the current file will be sent to the perl interpreter, afterwards the buffer is redrawn, so you will not see any output.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.