]> git.madduck.net Git - etc/vim.git/blob - .vim/snippets/perl.snippets

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

check in mediawiki syntax/ftplugin from wikipedia
[etc/vim.git] / .vim / snippets / perl.snippets
1 # #!/usr/bin/perl
2 snippet #!
3         #!/usr/bin/perl
4         
5 # Hash Pointer
6 snippet .
7          =>
8 # Function
9 snippet sub
10         sub ${1:function_name} {
11                 ${2:#body ...}
12         }
13 # Conditional
14 snippet if
15         if (${1}) {
16                 ${2:# body...}
17         }
18 # Conditional if..else
19 snippet ife
20         if (${1}) {
21                 ${2:# body...}
22         } else {
23                 ${3:# else...}
24         }
25 # Conditional if..elsif..else
26 snippet ifee
27         if (${1}) {
28                 ${2:# body...}
29         } elsif (${3}) {
30                 ${4:# elsif...}
31         } else {
32                 ${5:# else...}
33         }
34 # Conditional One-line
35 snippet xif
36         ${1:expression} if ${2:condition};${3}
37 # Unless conditional
38 snippet unless
39         unless (${1}) {
40                 ${2:# body...}
41         }
42 # Unless conditional One-line
43 snippet xunless
44         ${1:expression} unless ${2:condition};${3}
45 # Try/Except
46 snippet eval
47         eval {
48                 ${1:# do something risky...}
49         };
50         if ($@) {
51                 ${2:# handle failure...}
52         }
53 # While Loop
54 snippet wh
55         while (${1}) {
56                 ${2:# body...}
57         }
58 # While Loop One-line
59 snippet xwh
60         ${1:expression} while ${2:condition};${3}
61 # For Loop
62 snippet for
63         for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {
64                 ${4:# body...}
65         }
66 # Foreach Loop
67 snippet fore
68         foreach my $${1:x} (@${2:array}) {
69                 ${3:# body...}
70         }
71 # Foreach Loop One-line
72 snippet xfore
73         ${1:expression} foreach @${2:array};${3}
74 # Package
75 snippet cl
76         package ${1:ClassName};
77         
78         use base qw(${2:ParentClass});
79         
80         sub new {
81                 my $class = shift;
82                 $class = ref $class if ref $class;
83                 my $self = bless {}, $class;
84                 $self;
85         }
86         
87         1;${3}
88 # Read File
89 snippet slurp
90         my $${1:var};
91         { local $/ = undef; local *FILE; open FILE, "<${2:file}"; $$1 = <FILE>; close FILE }${3}