cs.snippets (7487B)
1 # cs.snippets 2 # =========== 3 # 4 # Standard C-Sharp snippets for snipmate. 5 # 6 # Largely ported over from Visual Studio 2010 snippets plus 7 # a few snippets from Resharper plus a few widely known snippets. 8 # 9 # Most snippets on elements (i.e. classes, properties) 10 # follow suffix conventions. The order of suffixes to a snippet 11 # is fixed. 12 # 13 # Snippet Suffix Order 14 # -------------------- 15 # 1. Access Modifiers 16 # 2. Class Modifiers 17 # 18 # Access Modifier Suffix Table 19 # ---------------------------- 20 # + = public 21 # & = internal 22 # | = protected 23 # - = private 24 # 25 # Example: `cls&` expands to `internal class $1`. 26 # Access modifiers might be doubled to indicate 27 # different modifiers for get/set on properties. 28 # Example: `pb+-` expands to `public bool $1 { get; private set; }` 29 # 30 # Class Modifier Table 31 # -------------------- 32 # ^ = static 33 # % = abstract 34 # 35 # Example: `cls|%` expands to `protected abstract class $1` 36 # 37 # On method and property snippets, you can directly set 38 # one of the common types int, string and bool, if desired, 39 # just by appending the type modifier. 40 # 41 # Type Modifier Table 42 # ------------------- 43 # i = integer 44 # s = string 45 # b = bool 46 # 47 # Example: `pi+&` expands to `public int $1 { get; internal set; }` 48 # 49 # I'll most propably add more stuff in here like 50 # * List/Array constructio 51 # * Mostly used generics 52 # * Linq 53 # * Funcs, Actions, Predicates 54 # * Lambda 55 # * Events 56 # 57 # Feedback is welcome! 58 # 59 # entry point 60 snippet sim 61 public static int Main(string[] args) { 62 ${1} 63 return 0; 64 } 65 snippet simc 66 public class Application { 67 public static int Main(string[] args) { 68 ${1} 69 return 0; 70 } 71 } 72 # if condition 73 snippet if 74 if (${1}) { 75 ${2} 76 } 77 snippet el 78 else { 79 ${1} 80 } 81 snippet ifs 82 if (${1}) 83 ${2} 84 # ternary conditional 85 snippet t 86 ${1} ? ${2} : ${3} 87 snippet ? 88 ${1} ? ${2} : ${3} 89 # do while loop 90 snippet do 91 do { 92 ${2} 93 } while (${1}); 94 # while loop 95 snippet wh 96 while (${1}) { 97 ${2} 98 } 99 # for loop 100 snippet for 101 for (int ${1:i} = 0; $1 < ${2:count}; $1${3:++}) { 102 ${4} 103 } 104 # foreach 105 snippet fore 106 foreach (var ${1:entry} in ${2}) { 107 ${3} 108 } 109 snippet foreach 110 foreach (var ${1:entry} in ${2}) { 111 ${3} 112 } 113 snippet each 114 foreach (var ${1:entry} in ${2}) { 115 ${3} 116 } 117 # interfaces 118 snippet interface 119 public interface ${1:`Filename()`} { 120 ${2} 121 } 122 snippet if+ 123 public interface ${1:`Filename()`} { 124 ${2} 125 } 126 # class bodies 127 snippet class 128 public class ${1:`Filename()`} { 129 ${2} 130 } 131 snippet cls 132 ${2:public} class ${1:`Filename()`} { 133 ${3} 134 } 135 snippet cls+ 136 public class ${1:`Filename()`} { 137 ${2} 138 } 139 snippet cls+^ 140 public static class ${1:`Filename()`} { 141 ${2} 142 } 143 snippet cls& 144 internal class ${1:`Filename()`} { 145 ${2} 146 } 147 snippet cls&^ 148 internal static class ${1:`Filename()`} { 149 ${2} 150 } 151 snippet cls| 152 protected class ${1:`Filename()`} { 153 ${2} 154 } 155 snippet cls|% 156 protected abstract class ${1:`Filename()`} { 157 ${2} 158 } 159 # constructor 160 snippet ctor 161 public ${1:`Filename()`}() { 162 ${2} 163 } 164 # properties - auto properties by default. 165 # default type is int with layout get / set. 166 snippet prop 167 ${1:public} ${2:int} ${3:} { get; set; }${4} 168 snippet p 169 ${1:public} ${2:int} ${3:} { get; set; }${4} 170 snippet p+ 171 public ${1:int} ${2:} { get; set; }${3} 172 snippet p+& 173 public ${1:int} ${2:} { get; internal set; }${3} 174 snippet p+| 175 public ${1:int} ${2:} { get; protected set; }${3} 176 snippet p+- 177 public ${1:int} ${2:} { get; private set; }${3} 178 snippet p& 179 internal ${1:int} ${2:} { get; set; }${3} 180 snippet p&| 181 internal ${1:int} ${2:} { get; protected set; }${3} 182 snippet p&- 183 internal ${1:int} ${2:} { get; private set; }${3} 184 snippet p| 185 protected ${1:int} ${2:} { get; set; }${3} 186 snippet p|- 187 protected ${1:int} ${2:} { get; private set; }${3} 188 snippet p- 189 private ${1:int} ${2:} { get; set; }${3} 190 # property - bool 191 snippet pi 192 ${1:public} int ${2:} { get; set; }${3} 193 snippet pi+ 194 public int ${1} { get; set; }${2} 195 snippet pi+& 196 public int ${1} { get; internal set; }${2} 197 snippet pi+| 198 public int ${1} { get; protected set; }${2} 199 snippet pi+- 200 public int ${1} { get; private set; }${2} 201 snippet pi& 202 internal int ${1} { get; set; }${2} 203 snippet pi&| 204 internal int ${1} { get; protected set; }${2} 205 snippet pi&- 206 internal int ${1} { get; private set; }${2} 207 snippet pi| 208 protected int ${1} { get; set; }${2} 209 snippet pi|- 210 protected int ${1} { get; private set; }${2} 211 snippet pi- 212 private int ${1} { get; set; }${2} 213 # property - bool 214 snippet pb 215 ${1:public} bool ${2:} { get; set; }${3} 216 snippet pb+ 217 public bool ${1} { get; set; }${2} 218 snippet pb+& 219 public bool ${1} { get; internal set; }${2} 220 snippet pb+| 221 public bool ${1} { get; protected set; }${2} 222 snippet pb+- 223 public bool ${1} { get; private set; }${2} 224 snippet pb& 225 internal bool ${1} { get; set; }${2} 226 snippet pb&| 227 internal bool ${1} { get; protected set; }${2} 228 snippet pb&- 229 internal bool ${1} { get; private set; }${2} 230 snippet pb| 231 protected bool ${1} { get; set; }${2} 232 snippet pb|- 233 protected bool ${1} { get; private set; }${2} 234 snippet pb- 235 private bool ${1} { get; set; }${2} 236 # property - string 237 snippet ps 238 ${1:public} string ${2:} { get; set; }${3} 239 snippet ps+ 240 public string ${1} { get; set; }${2} 241 snippet ps+& 242 public string ${1} { get; internal set; }${2} 243 snippet ps+| 244 public string ${1} { get; protected set; }${2} 245 snippet ps+- 246 public string ${1} { get; private set; }${2} 247 snippet ps& 248 internal string ${1} { get; set; }${2} 249 snippet ps&| 250 internal string ${1} { get; protected set; }${2} 251 snippet ps&- 252 internal string ${1} { get; private set; }${2} 253 snippet ps| 254 protected string ${1} { get; set; }${2} 255 snippet ps|- 256 protected string ${1} { get; private set; }${2} 257 snippet ps- 258 private string ${1} { get; set; }${2} 259 # members - void 260 snippet m 261 ${1:public} ${2:void} ${3:}(${4:}) { 262 ${5:} 263 } 264 snippet m+ 265 public ${1:void} ${2:}(${3:}) { 266 ${4:} 267 } 268 snippet m& 269 internal ${1:void} ${2:}(${3:}) { 270 ${4:} 271 } 272 snippet m| 273 protected ${1:void} ${2:}(${3:}) { 274 ${4:} 275 } 276 snippet m- 277 private ${1:void} ${2:}(${3:}) { 278 ${4:} 279 } 280 # members - int 281 snippet mi 282 ${1:public} int ${2:}(${3:}) { 283 ${4:return 0;} 284 } 285 snippet mi+ 286 public int ${1:}(${2:}) { 287 ${3:return 0;} 288 } 289 snippet mi& 290 internal int ${1:}(${2:}) { 291 ${3:return 0;} 292 } 293 snippet mi| 294 protected int ${1:}(${2:}) { 295 ${3:return 0;} 296 } 297 snippet mi- 298 private int ${1:}(${2:}) { 299 ${3:return 0;} 300 } 301 # members - bool 302 snippet mb 303 ${1:public} bool ${2:}(${3:}) { 304 ${4:return false;} 305 } 306 snippet mb+ 307 public bool ${1:}(${2:}) { 308 ${3:return false;} 309 } 310 snippet mb& 311 internal bool ${1:}(${2:}) { 312 ${3:return false;} 313 } 314 snippet mb| 315 protected bool ${1:}(${2:}) { 316 ${3:return false;} 317 } 318 snippet mb- 319 private bool ${1:}(${2:}) { 320 ${3:return false;} 321 } 322 # members - string 323 snippet ms 324 ${1:public} string ${2:}(${3:}) { 325 ${4:return "";} 326 } 327 snippet ms+ 328 public string ${1:}(${2:}) { 329 ${3:return "";} 330 } 331 snippet ms& 332 internal string ${1:}(${2:}) { 333 ${3:return "";} 334 } 335 snippet ms| 336 protected string ${1:}(${2:}) { 337 ${3:return "";} 338 } 339 snippet ms- 340 private string ${1:}(${2:}) { 341 ${3:return "";} 342 } 343 # structure 344 snippet struct 345 public struct ${1:`Filename()`} { 346 ${2} 347 } 348 # enumeration 349 snippet enum 350 public enum ${1} { 351 ${2} 352 } 353 # preprocessor directives 354 snippet #if 355 #if 356 ${1} 357 #endif 358 # inline xml documentation 359 snippet /// 360 /// <summary> 361 /// ${1} 362 /// </summary> 363 snippet <p 364 <param name="${1}">${2:$1}</param>${3} 365 snippet <ex 366 <exception cref="${1:System.Exception}">${2}</exception>${3} 367 snippet <r 368 <returns>${1}</returns>{${2} 369 snippet <s 370 <see cref="${1}"/>${2} 371 snippet <rem 372 <remarks>${1}</remarks>${2} 373 snippet <c 374 <code>${1}</code>${2}