honza/vim-snippets — pull request #220 by yydonny (2013-06-08 11:41:43+00:00)
Title: Some improvements to the snippets of CoffeeScript

I made the following improvements to `UltiSnips/coffee.snippets` in this pull request:

- For several snippets(e.g. `bfun`, `if`, `for*`, etc.), I removed the limit(`b`) of only being expanded when triggered at the beginning of the line. Since most statements in CoffeeScript are also assignable expressions(especially the `bfun`, which is almost always used anonymously within an expression), it's better to make those snippets available in the middle of a line.

- I modified the `fun` snippet to make the brackets a part of selections. This is useful when defining function without arguments. Besides, this is consistent with the behavior of `bfun`.

```
snippet fun "Function" b
${1:name} = ${2:(${3:args}) }->
${0:# body...}
endsnippet
```

- Interpolation is often used to suffix a token, so I made it an in-word snippet(adding `i`).

- It's better to have an 'else' clause in the `swi` snippet. This won't hurt since the coffee compiler automatically drops empty else.

```
snippet swi "Switch"
switch ${1:object}
when ${2:value}
${3:# body...}
else
$0
endsnippet
```

- Added a new `swit` snippet, which expands to the 'switch-when-then' statement.

```
snippet swit "Switch when .. then"
switch ${1:object}
when ${2:${3:condition} then ${4:value}}
else ${0:value}
endsnippet
```