https://github.com/natebosch/dartlang-snippets
UltiSnips snippets for Dart
https://github.com/natebosch/dartlang-snippets
dart ultisnip-snippets ultisnips vim
Last synced: 5 months ago
JSON representation
UltiSnips snippets for Dart
- Host: GitHub
- URL: https://github.com/natebosch/dartlang-snippets
- Owner: natebosch
- Created: 2016-01-26T21:48:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-08-20T17:15:11.000Z (about 4 years ago)
- Last Synced: 2025-05-07T06:02:44.097Z (5 months ago)
- Topics: dart, ultisnip-snippets, ultisnips, vim
- Language: Vim Snippet
- Size: 20.5 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UltiSnips snippets for Dart
A collection of snippets for writing Dart. Start by reading about [UltiSnips][]
if you haven't used if before.[UltiSnips]: https://github.com/SirVer/ultisnips
# Highlights
Some of the snippets that save the most typing.
## Dart code
### `im`
Import line. `imsome_package` becomes
`import 'package:some_package/some_package.dart';`### `for`
For-in loop. `forelement` becomes
```dart
for(var element in elements) {
|
}
```### `try`
Try-catch. Most useful from visual mode with a block selected, fills the
selection in the `try`, then tab to fill out the `catch`.[](https://asciinema.org/a/101189)
### Methods
Each of these triggers has 2 modes. At the beginning of the line they generate a
top-level/instance method. After other characters they generate a closure.- `m`
- `mReturnTypemethodNameArgType argument` becomes```dart
ReturnType methodName(ArgType argument) {
|
}
```
- After other characters: `margument` becomes```dart
(argument) {
|
}
```
- `r`
- `rReturnTypemethodNameArgType argument` becomes`ReturnType methodName(ArgType argument) => |`
- After other characters: `rargument` becomes`(argument) => |`
Prepending either trigger with `a` makes it use 'async mode'. For example, at
the beginning of a line:`arReturnTypemethodNameArgType argument` becomes
`Future methodName(ArgType argument) async => |`
## Angular Snippets
### `co`
A `@Component` annotation and class. Saves the most time if you follow a naming
convention: a class name `SomeName` has a selector like `some-name`, a template
at `some_name.html`, and styles at `some_name.css` or `some_name.scss.css`.
Fills out a default name which works well if this component lives in a file
named `some_name.dart`.[](https://asciinema.org/a/101181)
# Installation
Install this repository and UltiSnips using your favorite method. If you used
[vim-plug][]:```vimscript
Plug 'SirVer/Ultisnips'
Plug 'natebosch/dartlang-snippets'
```[vim-plug]: https://github.com/junegunn/vim-plug