forked from tommorris/scala-vim-snippets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scala.snippets
111 lines (110 loc) · 1.94 KB
/
scala.snippets
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
# documentation: if the snippet is prefixed by lines that start "## ", those can be used by
# a pre-processor script to create a quickref. the idea is that you can print such a file
# out and have it for quick reference while learning how to use the snippets for that
# particular language.
#
snippet class
class ${1:ClassName} {
${2}
}
## case class
snippet cclass
case class ${1:ClassName} {
${2}
}
snippet trait
trait ${1:TraitName} {
${2}
}
## singleton object
snippet object
object ${2:ObjectName} {
${2}
}
## application trait
snippet application
object ${1:ObjectName} extends Application {
${2}
}
## defines a type (e.g. structural)
snippet type
type ${1} = {${2}}
## method definition
snippet def
def ${1:method}(${2})${3: : ${4:Unit}} = {
${5}
}
## if conditional
snippet if
if (${1:condition}) {
${2:// expression}
}
snippet ifelse
if (${1:condition}) {
${2:// expression}
} else {
}
snippet while
while (${1:condition}) {
${2:// expression}
}
snippet try
try {
${2:// expression}
}
catch {
case e : ${1:Exception} => ${3:// expression}
}
## try..catch..finally
snippet tfc
try {
${2:// expression}
}
catch {
case e : ${1:Exception} => ${3:// expression}
}
finally {
${4:// expression}
}
## private
snippet pr
private
## scoped private
snippet pri
private[${1:this}]
## protected
snippet pro
protected
## scoped protected
snippet prop
protected[${1:this}]
snippet for
for (${1} <- ${2}) {
${3}
}
snippet foreach
foreach {${1} =>
${2}
}
snippet match
match {
case ${1} => ${2}
}
snippet case
case ${1} => ${2}
## println
snippet p
println(${1})
snippet main
def main(args: Array[String]) = {
${1}
}
## specifies arguments - x1
snippet 1
(${1:first}: ${2:Type})
## specifies arguments - x2
snippet 2
(${1:first}: ${2:Type}, ${3:second}: ${4:Type})
## specifies arguments - x3
snippet 3
(${1:first}: ${2:Type}, ${3:second}: ${4:Type}, ${5:third}: ${6:Type})