Skip to content

Instantly share code, notes, and snippets.

@saterus
Last active April 1, 2020 14:32
Show Gist options
  • Save saterus/c9997cc3323966c7ec89f74e2c40ec7a to your computer and use it in GitHub Desktop.
Save saterus/c9997cc3323966c7ec89f74e2c40ec7a to your computer and use it in GitHub Desktop.
VSCode Snippets for Elixir & EEx Templates
{
// Place your snippets for elixir here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
"Pry": {
"prefix": "pry",
"body": [
"require IEx",
"IEx.pry()",
"$0"
],
"description": "Insert pry statement"
},
"Print to console": {
"prefix": "log",
"body": [
"IO.inspect('$1');",
"$2"
],
"description": "Log output to console"
},
"Add @doc comment": {
"prefix": "doc",
"body": [
"@doc \"\"\"",
" $0",
"\"\"\""
],
"description": "Add some docs!"
},
"Add @moduledoc comment": {
"prefix": "mdoc",
"body": [
"@moduledoc \"\"\"",
" $0",
"\"\"\""
],
"description": "Add some docs!"
},
"Expand atom param": {
"prefix": "~m",
"body": [
"${1}: ${1},"
]
},
"Expand string param": {
"prefix": "~M",
"body": [
"\"${1}\" => ${1},"
]
},
"Expand test context args": {
"prefix": "ctx",
"body": [
"%{${1}: ${1},}"
]
},
"Insert new test": {
"prefix": "test",
"body": [
"test \"${1}\", %{${2}: ${2},} do",
" ${0}",
"end",
]
},
"Insert a pending test stub": {
"prefix": "test_stub",
"body": [
"test \"${1}\"",
"${0}"
],
"description": "Insert a pending test stub"
},
"Insert new describe block": {
"prefix": "describe",
"body": [
"describe \"${1}\" do",
" setup [${2}]",
"",
" ${0}",
"end"
],
"description": "Insert new describe block"
},
"Insert a test setup function": {
"prefix": "defp_setup",
"body": [
"defp create_${1}(${0:ctx}) do",
" [${1}: insert(:${1})]",
"end",
""
],
"description": "Insert a test setup function"
},
"Add Focus tag": {
"prefix": "focus",
"body": [
"@tag focus: true"
]
},
"Insert a dbg! statement": {
"prefix": "dbg",
"body": [
"|> dbg!()",
"${0}use Core.Debug"
],
"description": "Insert a dbg! statement"
},
"IO.inspect": {
"prefix": "ins",
"body": [
"IO.inspect(${1}, label: \"${1}\")",
"$0"
]
},
"IO.inspect in pipe": {
"prefix": "pins",
"body": [
"|> IO.inspect(label: \"${1}\")",
"$0"
]
},
"Insert inspect_fields pipeline": {
"prefix": "fins",
"body": [
"|> inspect_fields([${2}, ${3}], label: ${1})"
],
"description": "Insert inspect_fields pipeline"
},
"Insert a IO.puts() statement": {
"prefix": "puts",
"body": [
"IO.puts(\"${1}\")",
"${0}"
],
"description": "Insert a IO.puts() statement"
},
}
{
// Place your snippets for HTML (EEx) here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Single line interpolation": {
"prefix": "sl",
"body": [
"<%= $1 %>",
],
"description": "Single line interpolation"
},
"For loop": {
"prefix": "foreach",
"body": [
"<%= for $1 <- $2 do %>",
" <%= $0 %>",
"<% end %>",
],
"description": "EEx For Loop"
},
"If statement": {
"prefix": "if",
"body": [
"<%= if $1 do %>",
" <%= $2 %>",
"<% else %>",
" <%= $0 %>",
"<% end %>",
],
"description": "EEx conditional"
},
"End Eex": {
"prefix": "end",
"body": [
"$0",
"<% end %>",
],
"description": "End tag"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment