Skip to content

Instantly share code, notes, and snippets.

@YannickFricke
Created November 17, 2025 21:07
Show Gist options
  • Select an option

  • Save YannickFricke/06826bad4f746fd5f0a424e337a089d1 to your computer and use it in GitHub Desktop.

Select an option

Save YannickFricke/06826bad4f746fd5f0a424e337a089d1 to your computer and use it in GitHub Desktop.
My elixir VSCode snippets
{
"Inspect a value": {
"prefix": "ins",
"description": "Inspect a value with a label",
"body": [
"IO.inspect($1, label: \"$1\")"
]
},
"Pipe inspect": {
"prefix": "insp",
"description": "Inspect a value with a pipe operator",
"body": [
"|> IO.inspect(label: \"$1\")"
]
},
"Pipe operator": {
"prefix": "p",
"body": "|> "
},
"String type": {
"prefix": "string",
"body": "String.t()"
},
"t Type": {
"prefix": "tt",
"body": [
"@type t() :: %__MODULE__{",
" $1",
"}"
]
},
"t Type with timestamps": {
"prefix": "ttwts",
"body": [
"@type t() :: %__MODULE__{",
" id: $1,",
" $2",
" inserted_at: DateTime.t(),",
" updated_at: DateTime.t()",
"}"
]
},
"ecto fields": {
"prefix": "ef",
"body": [
"@required_fields ~w($1)a",
"",
" @optional_fields ~w($2)a"
]
},
"ecto migration uuid table": {
"prefix": "emut",
"body": [
"create table(:$1, primary_key: false) do",
" add :id, :uuid, null: false, primary_key: true",
" $2",
"end"
]
},
"ecto migration uuid table with timestamps": {
"prefix": "emutwts",
"body": [
"create table(:$1, primary_key: false) do",
" add :id, :uuid, null: false, primary_key: true",
" $2",
" add :inserted_at, :utc_datetime, null: false",
" add :updated_at, :utc_datetime, null: false",
"end"
]
},
"module": {
"prefix": "m",
"body": "__MODULE__"
},
"module struct": {
"prefix": "ms",
"body": "%__MODULE__{$0}"
},
"breakpoint": {
"prefix": "bp",
"body": ["require IEx", "IEx.pry()"]
},
"changeset": {
"prefix": "changeset",
"body": [
"@spec changeset(",
" entity_or_changeset :: t() | Ecto.Changeset.t(t()),",
" params :: map()",
" ) :: Ecto.Changeset.t(t())",
" def changeset(entity_or_changeset, params) do",
" entity_or_changeset",
" |> cast(params, @required_fields ++ @optional_fields)",
" |> validate_required(@required_fields)",
" $0",
" end"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment