I have a very flexible three-part system that turns Vim (my favorite editor) into the perfect Perl IDE for me. Part 1 is a shell script that creates the file, adds a shebang, a dated comment with the author's name, and a 'use strict;' -

#!/bin/bash # Created by Ben Okopnik on Mon Apr 28 11:41:01 EDT 2008 # Enter your name here; otherwise, your login name will be used name="" [ -z "$1" ] && { printf "Usage: $0 <file_to_create>\n"; exit; } [ -f "$1" ] && { printf "File already exists!\n"; exit; } printf "#!`which perl` -w\n" > $1 printf "# Created by ${name:-$USER} on `date`\nuse strict;\n\n\n" >> $ +1 chmod +x $1 vi + $1

The next two parts are Vim keymaps which live in my "~/.vimrc":

map <silent> <F2> :set filetype=perl<CR>:set kp=perldoc\ -f<CR>:0<CR>: +-r!which perl<CR>I#!<ESC>$a -w<ESC>o# Created by Ben Okopnik on^[:r!d +ate<CR>-J^<CR>iuse strict;<CR><CR> map <F5> :w<CR>:![ -x "%:p" ]\|\|chmod +x "%:p"<CR>:!"%:p"

The 'F2' key inserts the same content as the script would plus sets up a few useful things in Vim - e.g., hitting the 'K' key now runs 'perldoc -f ' instead of 'man ' on the word under the cursor. Perl syntax highlighting is also enabled. The 'F5' key saves the file, makes it executable if it's not already, then presents you with the command line dialog where hitting the 'Enter' key will execute the current file. You can also enter any arguments your script needs at that time. When it's done, you're returned to your Vi session.

I realize that this is more than just a template, but for me, that bit is pretty much inextricably tied up with all the rest of it. I'm too Lazy to use just templates. :)


-- 
Human history becomes more and more a race between education and catastrophe. -- HG Wells

In reply to Re: Suggested templates for Perl by oko1
in thread Suggested templates for Perl by tirwin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.