vim-snippets/snippets/perl-basic.snippets

159 lines
1.7 KiB
Plaintext
Raw Normal View History

2011-06-27 16:13:31 -04:00
# #!/usr/bin/perl
# strict warnings
snippet strwar
use strict;
use warnings;
# standard versioning with perlcritic bypass
snippet vers
## no critic
our $VERSION = '${1:version}';
eval $VERSION;
## use critic
2011-06-27 16:32:23 -04:00
# new 'switch' like feature
snippet switch
use feature 'switch';
2011-06-27 16:13:31 -04:00
# Anonymous subroutine
snippet asub
sub {
${1:# body }
}
2011-06-27 16:32:23 -04:00
2011-06-27 16:13:31 -04:00
# Begin block
snippet begin
BEGIN { #{{{
${1:# begin body}
} #}}}
2011-06-27 16:32:23 -04:00
# call package function with some parameter
snippet pkgmv
2011-06-27 16:13:31 -04:00
__PACKAGE__->${1:package_method}(${2:var});
2011-06-27 16:32:23 -04:00
# call package function without a parameter
snippet pkgm
__PACKAGE__->${1:package_method}();
# call package "get_" function without a parameter
snippet pkget
__PACKAGE__->get_${1:package_method}();
# call package function with a parameter
snippet pkgetv
__PACKAGE__->get_${1:package_method}(${2:var});
2011-06-27 16:13:31 -04:00
# complex regex
snippet qrx
qr/
${1:regex}
/xms
#simpler regex
snippet qr/
qr/${1:regex}/x
2011-06-27 16:32:23 -04:00
#given
snippet given
given ($${1:var}) { #{{{
2011-06-27 16:13:31 -04:00
${2:# cases}
2011-06-27 16:32:23 -04:00
${3:# default}
2011-06-27 16:13:31 -04:00
} #}}}
2011-06-27 16:32:23 -04:00
# switch-like case
snippet when
when (${1:case}) { #{{{
2011-06-27 16:13:31 -04:00
${2:# body}
2011-06-27 16:32:23 -04:00
} #}}}
# hash slice
snippet hslice
@{ ${1:hash} }{ ${2:array} }
# map
snippet map
map { ${2: body } } ${1: @array } ;
# Pod stub
snippet ppod
=head1 NAME
${1:ClassName} - ${2:ShortDesc}
=head1 SYNOPSIS
use $1;
${3:# synopsis...}
=head1 DESCRIPTION
${4:# longer description...}
=head1 INTERFACE
=head1 DEPENDENCIES
=head1 SEE ALSO
# Heading for a subroutine stub
snippet psub
=head2 ${1:MethodName}
${2:Summary....}
# Subroutine signature
snippet parg
=over 2
=item
Arguments
=over 3
=item
C<${1:DataStructure}>
${2:Sample}
=back
=item
Return
=over 3
=item
C<${3:...return data}>
=back
=back
2011-06-27 16:13:31 -04:00