3 ms·
for anyone using Elixir + vscode, this snippet is invaluable: { "Inspect": { "prefix": "ins", "body": "|> IO.inspect(label: \"$0$TM_LINE_N
by dnautics 5y ago
for anyone using Elixir + vscode, this snippet is invaluable:
{
"Inspect": {
"prefix": "ins",
"body": "|> IO.inspect(label: \"$0$TM_LINE_NUMBER\")",
"description": "Adds a pipeline with a labelled `IO.inspect`",
}
}
when you type ins<tab> it injects a labelled IO.inspect that makes it easy to track where the data came from; usually in a debugging session the line numbers will be sufficient to track, and more importantly, it's almost always easy to ninja out these IO.inspects in one shot, because they are almost always the same number of characters long (since contiguous line numbers are usually in the same decade). Credit goes to one of my former junior devs who built this.
video demo: https://www.youtube.com/watch?v=JXQZhyPK3Zw&t=1410s https://www.youtube.com/watch?v=JXQZhyPK3Zw&t=1410s (note slickbits doesn't seem to exist anymore)
- AlchemistCamp 5y agoI have almost the same one in my elixir.json when I use VS Code! I'm pretty sure your YT channel was the inspiration, and I've used that snippet a ton over the past year or two. "Inspect": { "prefix": "ins", "body": "|> IO.inspect(label: \"${1:$TM_LINE_NUMBER}\")$0", "description": "Adds a pipeline with a labelled `IO.inspect`", } The only difference is that my version above makes the line number into a tab stop section so it's quick to swap out with another label.
- bostonvaulter2 5y agoHere's an emacs yas-snippet that does the same thing (and was inspired by yours) # -*- mode: snippet -*- # name: Piped Inspect # key: pin # -- |> IO.inspect(label: "$2$1 (`(buffer-name)`:`(line-number-at-pos))`)") I also like to use a non-piped version: # -*- mode: snippet -*- # name: Labeled Inspect # key: lin # -- IO.inspect($1, label: "$2$1 (`(buffer-name)`:`(line-number-at-pos))`)") And occasionally a logger-based one: # -*- mode: snippet -*- # name: Logger Inspect # key: logi # -- Logger.info("$2$1: #{inspect($1)}")
- mercer 5y agoI use Keyboard Maestro for this. "iins" for IO.inspect(), "ppry" for require IEx; IEx.pry, and ">>" for |>. This way I can use these shortcuts in IEx, emacs, vscode, LiveBook, etc.