We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
ElixirConf · 828 views · 25 likes
Analysis Summary
Worth Noting
Positive elements
- Provides highly specific, practical configurations for Elixir developers to improve their REPL workflow, particularly the Vim/TTY integration.
Influence Dimensions
How are these scored?About this analysis
Knowing about these techniques makes them visible, not powerless. The ones that work best on you are the ones that match beliefs you already hold.
This analysis is a tool for your own thinking — what you do with it is up to you.
Related content covering similar topics.
Beyond your first NIF - Riccardo Binetti | Code BEAM Europe 2025
Code Sync
Announcing RunElixir.com
Peter Ullrich
Shared secrets management in Livebook Teams
Dashbit
Optimizing the BEAM's Scheduler for Many-Core Machines - Robin Morisset | Code BEAM Europe 2025
Code Sync
Parallel Map in Erlang
BEAM Channel - Erlang & Elixir
Transcript
[Applause] [Music] [Applause] [Music] Hi. Uh, my name is Brett Batty. Uh, I work to, uh, make Surge the easiest SMS API for developers. And I'm here today to talk about IEX. Um, so IEEX is Elixir's interactive shell. Um, which if you kind of squint is like an MCP server but for people. >> Um, and it it's really uh how I like to interface with my app. Um, it lets me call any of the code that I want. Um, I don't have to respect domain boundaries. I can even like temporarily make functions public just to try them out. Um, but it gives me like a really strong like feedback loop. I can call a function, see that it returns what I'm expecting or change my expectations and um uh just yeah integrate things a lot faster. Um, and especially for like unfamiliar parts of the code or unfamiliar dependencies. Um, it it lets me figure out quickly, is this function going to do what I expect it to do? Um, do I need to kind of change how I'm calling it? Uh, lets me try it out without spending too much time having other code call it. Um, and one of the most um, ubiquitous things in IEX is helper functions. Like you kind of forget they're even there. They're just functions that improve the experience and um, give you access to do what you need but still feel like part of the shell. So examples are like the vh helper which is previous results. Uh, there's recompile, which I use way more than um pretty much anything. Uh, there's h for give me the docs for this. And I'm not going to list all the helpers, but there's even a helper to list all the helpers. If you just hit h with no arguments, it does the docs forex.helpers, which is most of the built-in ones. Um, but you can also build your own helper functions. Um like I said it inter uh ex is like the interface with your project and you can extend the helpers to better match that interface. Um, so it's surge, we're doing SMS stuff and it's easy enough to send a message and like not actually send it, but when we want to in dev like receive like text messages. Um, in real life we're getting that from somewhere else and not initiating it on our server. So we have like a helper to like pretend to receive a text message. Um or we've got some that like retrieving data. I found myself often like okay take my schema do an ectoquery limit one then call repo.1 because I just need something to call this function but it doesn't actually matter which one. um or we use typed ids and so instead of saying okay repo.get get account ID. I can just say get me the thing with this ID. Um, and in the past I've transcoded strings, signed stuff like uh JWTs that my server would accept. Um, there's just a lot anything that you find yourself doing in IEX that you're like, I think my code can do this better. I think would make for a good helper. Um, and there's kind of a because you can call any of your code, there's uh not a clear line between like what's like a helper and what's just a function in my code. Um, and so sort of where I would draw the line is anything that's going to be used by somewhere else in your project should probably go in lib um, and be compiled with your project. Anything that you just do inex, it's just there for you. Uh, you can stick in yourex.exs. Um, you do have to, um, like make sure it exists. I've worked in, um, projects before where it just assumes you run ex-sm mix. Um, but then it like blows up if you just want to runex and not load the whole project. Um, but you can do that with like code and sure loaded. Um, and uh, kind of a neat thing with withex or theex.exs file is it's evaluated line by line, which is just like subtly different from every other.exs file you're ever going to use. Um, because uh, so like in this example, we're importing my app.exhelpers in the same file where it's defined. Um, anywhere else that's not going to work, but because this is basically like you're putting that straight in ex um, it works. Um, and but that also lets you do things like if you did define a variable in this file, you'll also have access to that in the shell. Um, and so what one thing that we wanted to do at Serge 2 was uh like for example that get helper or um any of our aliases we wanted when we would do like a remote shell into prod. And so, uh, my brother Dennis, uh, experimented and figured out how to get, um, theix.exs file into the release. Um, and so there's like the real overlays directory. Um, and if you put files into that, then they're copied into your release. And so in our docker file, we just have a step that copies our dev one over to that or you could do an entirely separate like prod only one. Um, but the thing to note with that is it's b uh the path to this.ex.exs accesss file is based on the directory from where you like start the session and not from where you call the remote command. Um just yeah in case that bites you. Um, but then one of the big uh problems or not problems but uh frustrations for me with IEX is new lines. Um, I don't know about you, but I've had a lot of times where I've pasted in like a multi-line command, realized I got like a line wrong, and then I hit like up seven times, hit that line, repeat, repeat, change a line, repeat, repeat. Um, and so I wanted to improve like the multi-line story. Um and kind of the first thing I found and but there is some stuff that um it it does do well. So they introduced like piping. Um it's not in the picture, but if you do a line and then you start the next uh command with a pipe, it'll pipe the previous result into that function like a real pipe or like a pipe in your main code. Um, but it there there's some like quirks with that where if you do like an assignment, you can't bind the whole pipe because it thinks it's like just the first thing and so actually doesn't then let you pipe into stuff. So you can't just like paste code in there all the time. Um, and then uh they they do have a nice little like way to break out of um stuff. So, I don't know about y'all, but matching up brackets and parentheses and stuff doesn't always work. So, in this example, we forget to close a quote. You hit enter and it's like, "Oh, shoot. Something didn't line up. Let me try closing. That didn't work. That didn't work." Um, and before I would just like close out of IEX and restart it. Uh, but they do have a nice little likeex break comment that you can add that just kills the current command and lets you start over, which is nice. Um, but then I found out there is a it doesn't work for quotes, so it wouldn't have helped in this situation. But if you do control and close bracket, it'll actually like close matching braces brackets parenthesis, which is pretty sweet. Um, okay. But now like uh so the docs for IEX I feel like are like there's the ex docs which I feel like are great but then there's like the Erling shell that that builds on and then there's a TTY module uh where a lot of um this next content comes from. Uh, so if you're ever interested in like what can I do with the line editing in IEX, the TTY module in Erling is a great place to look. Um, but the first kind of breakthrough I had is uh your meta key. So like option or alt, if you hold that and press enter, it does a new line without submitting the previous input. And so it lets you do multi-line input and then you can go up and down with option up or down. Um and that's you can also do it with an escape. So if you press escape and then hit enter um it does the same thing which will be important in the next couple slides. Um, but then I found out on the Elixir Slack that you can actually jump into your editor from IEX. Um, so there's uh kind of a convention where you have a an editor envar or you can do visual kind of on top of that and it's a command that gets run for your editor. Um, so I think a lot of times it'll default to like nano or something or if you're a Vim person, you might set it to that. And you may have seen it if you do like get commit and forget the message flag. Um, it'll like prompt you to write a commit message. And so you can do kind of that same thing with this. Um, and so you just hit do a meta O and that opens your editor, uh, waits for you to save it and quit and, uh, the temporary file that it gave your editor, the contents will be put inex. Um, and if you're doing a guey like VS Code or cursor, anything like that, there's usually a d-we flag when you set visual that will um say don't like once it pops open your editor, the process that you started doesn't quit until your editor closes. Um, and that's going to be important to let X know when that temporary file has been written to. Um, it does open as a URL file because it comes from the Erling shell. So, um, I have an auto command in Vim in this example that uh, sets my file type to elixir. So, I actually get all the perks of that. Um, but a problem with this as it comes is when you save the file, it goes back to individual line history. So even if you have a multi-line input, go into your editor, write it back, then it's a bunch of individual lines in history, and you're back to heading up a dozen times. Um, and so I wanted to uh combine uh the uh meta enter from the previous slide with this ability. And uh I kind of worked through this with someone on the elixir slack. I forget who it was, but um kind of a co-effort there. Um, but if you recall from the meta enter, we discovered that was the same as like escape plus enter. And um, so you can get kind of the same thing if you just write those escapes into your into that file. Um, and so that's what this is what they look like in Vim. It's not a carrot bracket. That's just how it represents the escape. And so if you just write the escape on each line, save and quit, it'll go back to being one kind of input item one. And um yeah, that's kind of nice. Uh one one thing I did notice with that is it like um the second to last line sometimes would render a little funny. And so there's another in the TTY docs again there's a redraw line that's metal L and so if you do an escape L at the end that will redraw the whole thing and that seems to solve it for me. Um, and so combining all of this and um, in my Vim I have an auto command that just does this anytime I save a file that looks like this temporary file. And um so it lets me uh do multi-line into the uh ex uh go back in history, change it, rewrite it, and uh it works well for me. I guess I should have, you know, included a GIF of that with all the other GIFs. But, um, there are just a lot of features in IEX that, um, yeah, I just hadn't really explored. I I feel like it's easy to learn like the very basics and okay, I can like run code in this. Um, but there's like a debugger in it and uh there's like a switching menu so you can do multiple shells in the same ex session and so you can like yeah run one switch to another one like opening a new tab almost come back to the original um and then in the break menu there's a lot of um yeah just runtime information you can get with tables and modules and And I just, yeah, think ex is neat. And as I learn more about it, I feel like I can reach for it when more uh when I would normally reach for other tools. And um yeah, I just think it's neat. Um so just calling out do work at Serge have a bunch of stickers if you want them, but um think I have time for questions. [Applause] That was cool. Do you mind sharing a a link to your dot files if they're public so people can see the auto command? >> Yeah. Um, let's see. Wait a minute. They aren't public right now. I'm not against them being public. I just don't um see. Oh, one thing I didn't mention is you can also in so the writing with the um escapes characters that also works if you copy and paste into your shell. It'll usually say, "Hey, this looks a little fishy because there's non-printed characters." But if you um but if uh you select like I'm okay with that, it'll work usually except I use elacrity which doesn't which strips those out. Um sorry my dot files are not great right now. Let me Here we go. Um, so I have a on buff read for it looked the format for this looked different on my Linux machine than on this Mac one. So you might need to play with that. But set the file type to elixir. And then I I preferred doing a write pre so that I could actually see the um escapes as they were written. And so I just remove any existing escapes or escape L's uh anytime you write. And then uh anytime where there's a new line, I put a new escape. And then at the very end of the file, I put an L. Hey, uh, can you show where the TTY docs are that you were talking about? >> Yeah. Um, so that's um, so yeah, that's pulled up. Uh, so it's the Z like runtime. Um, there's just a TTY thing there. And so it lists like we talked about the um meta L for redrawing. Um I guess C like control O might work. I don't think it did on my machine, but I have different key bindings. Okay, we're at time. But thanks for coming. [Applause] [Music] [Applause] [Music]
Video description
✨This talk was recorded at ElixirConf US 2025. If you're curious about our upcoming event, check https://elixirconf.com✨ IEx, Elixir’s interactive shell, is a powerful tool hiding in plain sight. Even after years of daily use, I keep uncovering features that make development faster, debugging smoother, and exploration more fun. In this talk, you’ll learn how to level up your IEx workflow—from improving multi-line history and input, to building your own helper functions, to recovering gracefully from half-baked commands, to making your .iex.exs available to remote shells. Even if you’ve been using IEx for a while, you’ll walk away with practical techniques and lesser-known features that can help you get even more out of your day-to-day Elixir development. Let's keep in touch! Follow us on: 💥 Bluesky: https://elixirconf.bsky.social 💥 X: / elixirconf 💥 LinkedIn: / elixirconf