Code Monkey home page Code Monkey logo

vscode-postfix-dart's Introduction

vscode-postfix-dart

MarketPlace Tag Visual Studio Marketplace Downloads

Postfix templates for Dart

Features

This extension features postfix templates that can be used to improve productivity. It's been inspired on former, great TypeScript/JavaScript extension.

I find it annoying to jump the cursor back and forth whenever I want to perform some simple operations. This extension makes it easier. I use this feature on daily basis in C# but was missing it in Dart until now.

All available templates (expr means the expression on which the template is applied):

Template Outcome
.if if (expr)
.else if (!expr)
.null if (expr == null)
.notnull if (expr != null)
.for for (var i = 0; i < expr.length; i++)
.forin for (let item in expr)
.foreach expr.forEach((item){} )
.not !expr
.return return expr
.var var name = expr
.varType SomeType name = expr
.const const name = expr
.print print(expr)
.castis expr is SomeType
.castas expr as SomeTyp

Custom templates (1.6.0 and above)

You can now add your own templates if the defaults are not enough. This will only work for simple ones as some templates require additional tricky handling. To configure a template you need to set postfix.customTemplates setting. It's an array of the following objects:

{
  "name": "...",
  "description": "...",
  "body": "...",
  "when": ["..."]
}

name defines what will be the name of the suggestion description will show additional optional description when suggestion panel is opened body defines how the template will work (see below) when defines conditions when the template should be suggested

Template body

Template body defines how will the expression before the cursor be replaced. It supports standard Visual Studio Code Snippet syntax. There is also one special placeholder that can be used:

  • {{expr}}: this will be replaced by the expression on which the template is applied so for example !{{expr}} will simply negate the expression

Template conditions

when condition can be zero or more of the following options:

  • identifier: simple identifier, ie. variableName (inside an if statement or function call arguments)
  • expression: can be either a simple expression like object.property.value or array[index] or a combination of them
  • binary-expression: a binary expression, ie. x > 3, x * 100, x && y
  • unary-expression: an unary expression, ie. !x, x++ or ++x
  • function-call: a function call expression, ie. func(), object.method() and so on

If no conditions are specified then given template will be available under all possible situations

Configuration

This plugin contributes the following settings:

Known issues

Feel free to open issues for whatever you think may improve the extension's value. New ideas for more templates are also welcome. Most of them are pretty easy to implement.

vscode-postfix-dart's People

Contributors

ipatalas avatar adrieankhisbe avatar dependabot[bot] avatar coffee0127 avatar jrieken avatar ypresto avatar

Stargazers

Tony  avatar xubodux avatar

Watchers

James Cloos avatar Dmytro Kravtsov avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.