/usr/share/vim/addons/snippets/perl.snippets is in vim-snippets 1.0.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | # #!/usr/bin/perl
snippet #!
#!/usr/bin/env perl
# Hash Pointer
snippet .
=>
# Function
snippet sub
sub ${1:function_name} {
${0}
}
# Conditional
snippet if
if (${1}) {
${0}
}
# Conditional if..else
snippet ife
if (${1}) {
${2}
}
else {
${0}
}
# Conditional if..elsif..else
snippet ifee
if (${1}) {
${2}
}
elsif (${3}) {
${4:# elsif...}
}
else {
${0}
}
snippet eif
elsif (${1}) {
${0}
}
# Conditional One-line
snippet xif
${1:expression} if ${2:condition};
# Unless conditional
snippet unless
unless (${1}) {
${0}
}
# Unless conditional One-line
snippet xunless
${1:expression} unless ${2:condition};
# Try/Except
snippet eval
local $@;
eval {
${1:# do something risky...}
};
if (my $e = $@) {
${0:# handle failure...}
}
# While Loop
snippet wh
while (${1}) {
${0}
}
# While Loop One-line
snippet xwh
${1:expression} while ${2:condition};
# C-style For Loop
snippet cfor
for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
${0}
}
# For loop one-line
snippet xfor
${1:expression} for @${2:array};
# Foreach Loop
snippet for
foreach my $${1:x} (@${2:array}) {
${0}
}
# Foreach Loop One-line
snippet fore
${1:expression} foreach @${2:array};
# Package
snippet package
package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`};
${0}
1;
__END__
# Package syntax perl >= 5.14
snippet packagev514
package ${1:`substitute(vim_snippets#Filename('', 'Page Title'), '^.', '\u&', '')`} ${2:0.99};
${0}
1;
__END__
#moose
snippet moose
use Moose;
use namespace::autoclean;
${1:#}BEGIN {extends '${2:ParentClass}'};
${0}
# parent
snippet parent
use parent qw(${0:Parent Class});
# Read File
snippet slurp
my $${1:var} = do { local $/; open my $file, '<', "${2:file}"; <$file> };
${0}
# strict warnings
snippet strwar
use strict;
use warnings;
# older versioning with perlcritic bypass
snippet vers
## no critic
our $VERSION = '${0:version}';
eval $VERSION;
## use critic
# new 'switch' like feature
snippet switch
use feature 'switch';
# Anonymous subroutine
snippet asub
sub {
${0}
}
# Begin block
snippet begin
BEGIN {
${0}
}
# call package function with some parameter
snippet pkgmv
__PACKAGE__->${1:package_method}(${0:var})
# call package function without a parameter
snippet pkgm
__PACKAGE__->${0:package_method}()
# call package "get_" function without a parameter
snippet pkget
__PACKAGE__->get_${0:package_method}()
# call package function with a parameter
snippet pkgetv
__PACKAGE__->get_${1:package_method}(${0:var})
# complex regex
snippet qrx
qr/
${0:regex}
/xms
#simpler regex
snippet qr/
qr/${0:regex}/x
#given
snippet given
given ($${1:var}) {
${2:# cases}
${0:# default}
}
# switch-like case
snippet when
when (${1:case}) {
${0}
}
# hash slice
snippet hslice
@{ ${1:hash} }{ ${0:array} }
# map
snippet map
map { ${0: body } } ${1: @array } ;
# Pod stub
snippet ppod
=head1 NAME
${1:ClassName} - ${2:ShortDesc}
=head1 SYNOPSIS
use $1;
${3:# synopsis...}
=head1 DESCRIPTION
${0:# longer description...}
=head1 INTERFACE
=head1 DEPENDENCIES
=head1 SEE ALSO
# Heading for a subroutine stub
snippet psub
=head2 ${1:MethodName}
${0:Summary....}
# Heading for inline subroutine pod
snippet psubi
=head2 ${1:MethodName}
${0:Summary...}
=cut
# inline documented subroutine
snippet subpod
=head2 $1
Summary of $1
=cut
sub ${1:subroutine_name} {
${0}
}
# Subroutine signature
snippet parg
=over 2
=item
Arguments
=over 3
=item
C<${1:DataStructure}>
${2:Sample}
=back
=item
Return
=over 3
=item
C<${0:...return data}>
=back
=back
# Moose has
snippet has
has ${1:attribute} => (
is => '${2:ro|rw}',
isa => '${3:Str|Int|HashRef|ArrayRef|etc}',
default => sub {
${4:defaultvalue}
},
${0:# other attributes}
);
# override
snippet override
override ${1:attribute} => sub {
${2:# my $self = shift;};
${0:# my ($self, $args) = @_;};
};
# use test classes
snippet tuse
use Test::More;
use Test::Deep; # (); # uncomment to stop prototype errors
use Test::Exception;
# local test lib
snippet tlib
use lib qw{ ./t/lib };
#test methods
snippet tmeths
$ENV{TEST_METHOD} = '${0:regex}';
# runtestclass
snippet trunner
use ${0:test_class};
$1->runtests();
# Test::Class-style test
snippet tsub
sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {
my $self = shift;
${0}
}
# Test::Routine-style test
snippet trsub
test ${1:test_name} => { description => '${2:Description of test.}'} => sub {
my ($self) = @_;
${0}
};
#prep test method
snippet tprep
sub prep${1:number}_${2:test_case} :Test(startup) {
my $self = shift;
${0}
}
# cause failures to print stack trace
snippet debug_trace
use Carp; # 'verbose';
# cloak "die"
# warn "warning"
$SIG{'__DIE__'} = sub {
require Carp; Carp::confess
};
|