From 9054a6e9f5eaa7f05d476ebb630c12467925c6d7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 3 Jun 2009 23:51:04 -0500 Subject: rewrite the perl snippets with what i had in snippetsemu --- vim/snippets/perl.snippets | 115 +++++++++++++++------------------------------ 1 file changed, 38 insertions(+), 77 deletions(-) (limited to 'vim') diff --git a/vim/snippets/perl.snippets b/vim/snippets/perl.snippets index cf8f9fc..82348e6 100644 --- a/vim/snippets/perl.snippets +++ b/vim/snippets/perl.snippets @@ -1,91 +1,52 @@ # #!/usr/bin/perl snippet #! - #!/usr/bin/perl + #!/usr/bin/env perl -# Hash Pointer -snippet . - => -# Function snippet sub - sub ${1:function_name} { - ${2:#body ...} + sub ${1:foo} { + $2 } -# Conditional snippet if - if (${1}) { - ${2:# body...} + if (${1:cond}) { + $2 } -# Conditional if..else -snippet ife - if (${1}) { - ${2:# body...} - } else { - ${3:# else...} +snippet elsif + elsif (${1:cond}) { + $2 } -# Conditional if..elsif..else -snippet ifee - if (${1}) { - ${2:# body...} - } elsif (${3}) { - ${4:# elsif...} - } else { - ${5:# else...} +snippet else + else { + $1 } -# Conditional One-line -snippet xif - ${1:expression} if ${2:condition};${3} -# Unless conditional -snippet unless - unless (${1}) { - ${2:# body...} - } -# Unless conditional One-line -snippet xunless - ${1:expression} unless ${2:condition};${3} -# Try/Except -snippet eval - eval { - ${1:# do something risky...} - }; - if ($@) { - ${2:# handle failure...} - } -# While Loop -snippet wh - while (${1}) { - ${2:# body...} - } -# While Loop One-line -snippet xwh - ${1:expression} while ${2:condition};${3} -# For Loop snippet for - for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) { - ${4:# body...} + for my $${1:var} (${2:1..10}) { + $3 } -# Foreach Loop -snippet fore - foreach my $${1:x} (@${2:array}) { - ${3:# body...} +snippet fora + for my $${1:var} (@${2:array}) { + $3 } -# Foreach Loop One-line -snippet xfore - ${1:expression} foreach @${2:array};${3} -# Package -snippet cl - package ${1:ClassName}; - - use base qw(${2:ParentClass}); - - sub new { - my $class = shift; - $class = ref $class if ref $class; - my $self = bless {}, $class; - $self; +snippet while + while (${1:cond}) { + $2 } +snippet eval + eval {$1}; + if ($@) { + $2 + } +snippet st + map { $_->[0] } + sort { $a->[1] ${3:cmp} $b->[1] } + map { [$_, ${2:function}] } + ${1:list} +snippet tbl + local $Test::Builder::Level = $Test::Builder::Level + 1; + +snippet ccl + local $Carp::CarpLevel = $Carp::CarpLevel + 1; - 1;${3} -# Read File -snippet slurp - my $${1:var}; - { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = ; close FILE }${3} +# XXX: i'd like to allow for a tab to jump to the next line, but snipmate +# seems to be buggy with a lone tabstop at the end of a snippet +snippet linc + local $${1:a} = $$1 + ${2:1}; -- cgit v1.2.3-54-g00ecf