Check out a free preview of the full Developer Productivity, v2 course

The "Why Neovim" Lesson is part of the full, Developer Productivity, v2 course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen shares his personal preferences for using VIM and reasons for choosing certain tools and terminals. He briefly demonstrates some features of the Neovim API and a collection of small games called VimBeGood to practice VIM motions.

Preview
Close

Transcript from the "Why Neovim" Lesson

[00:00:00]
>> ThePrimeagen: So why neovim? Why not just using an IDE in Vim motions? I'm sure a lot of people ask me that same question, and you probably ask me that same question. Really for me, it's just that I want something I can edit and make it exactly the way I want.

[00:00:13]
And also, I don't like Microsoft. So I wouldn't use VS Code either way, but I'd use something like zed. The thing is, is I just want to be able to completely make it the exact way I want it, so it really comes down to Emacs or Vim, question.

[00:00:26]
>> Speaker 2: I just wanna shout out that if you wanna learn Vim deeper, you have a course on Frontend Masters.
>> ThePrimeagen: I do have a course on Frontend Masters on Vim, this is true.
>> Speaker 2: They're already here. They can jump to that course via the annotation that will be inserted.

[00:00:38]
>> ThePrimeagen: That was my first course ever. Somehow convinced, this is back when you're really Frontend, you're only Frontend. I was like your first non-frontend course practically. One of like three first non-frontend courses.
>> Speaker 2: Not too many, but we had some.
>> ThePrimeagen: We had some. Now you got lots.

[00:00:53]
So there you go, that's really why I do, I just want that, I kind of like the Lean experience. I also like the ability to have every single directory I can navigate to and then have that editor open at that location. So they're each their own kind of experience, I like to stay in the terminal, I don't really want to leave the terminal.

[00:01:10]
I'm not really a non-terminal guy, I don't like GUIs, I don't wanna click buttons, I wanna mash things. And long after the AI takes over, someday in 1000 years, whatever that time comes with, they actually produce a smart LLM that can actually do something and no longer we need the program.

[00:01:27]
I'll probably still just wanna match keys, use Vim, and build stuff, cuz I just enjoy the process of doing it. And so, why do I use it? I don't know, I'm a Luddite, if that's the proper answer, that's who I am, yes
>> Speaker 3: You think the Vim motions and the keyboard-based development is more powerful than compared to the environment side of VIM in that relationship.

[00:01:47]
>> ThePrimeagen: Yeah, I think that's the better part.
>> Speaker 3: Yeah.
>> ThePrimeagen: Because that one's universal in the sense that if you learn Vim motions and then you have to go do program Java, I'm just gonna use IntelliJ if I'm going to have to go program Java, that's the It's the reality.

[00:02:00]
They have a great way in motions, it's like, I'm already at home, I just need to learn some IntelliJ ways of doing things. And it's just like, okay, every editor I go to already has these pre built-in motions, and they're mostly all the same, so therefore, I can really kind of just move fast in any editor.

[00:02:15]
And so, I think that, that is definitely the plus. But for me, it's more than that. And that's the fact that I can do anything I want within it. And so, kind of to show a little bit, I was gonna show a little bit of kind of playing around with the Neovim API.

[00:02:26]
So if you ever get so curious you wish to open it up, I could show you how to do that. It's pretty, pretty dang simple. Let me just undo this, so I can have that as fun input at some other time. So what I'm gonna do is I'm just going to create a test.lua.

[00:02:39]
It's in Lua, so if you have never used Lua, Lua is actually a pretty fun programming language, it has some oddities. It use one-based indexing, which some people would argue is the superior indexing, I would argue they're wrong, but that's just me, okay? So the nice part about Neovim is, you can do anything, you can start programming, you can go print, hello world.

[00:02:59]
And I've just created a function, let's call it hello. And I can just simply execute hello right here. And of course, there we go. Now, to execute this in Neovim, I can just go :SO, that will source this file and it will run it, so there we go.

[00:03:12]
Hello world, right there in the bottom. You can see that in the bottom left. And so, it just runs, which means that you can just test scripts, you can just run things. Which means, if you're familiar with the help API, there's ways to go around it, you can say h, and then you can go vim_api.nvim.

[00:03:26]
You can try r, sorry, not that way. You go nvim_ and this will show you every single of the APIs that you have available. There's a bunch of APIs that you can do. And so, I have it on fuzzy find, it's just easier that way, so I can go like nvim_openwindow.

[00:03:42]
So open window takes in a buffer, if it should enter that and the configuration. So just to make it easy, I'm gonna go right down here to the example, and I'm just going to yank that one, put it down here, and I'm just gonna paste that in here, and I'm gonna go, shout out.

[00:03:55]
I now just created a little window right here, so we have our own window, which is this window also. But I didn't enter it, so I can go true, so I can just enter the window, shout it out, and now I'm in that window. So you can see it right there, the exact same buffer, I just created the same buffer in a new window, size 3 by 12, right?

[00:04:17]
And so, you can build whatever you want, and it's relatively simple, that was not hard to create, that was really simple to create. The entire API is like that where you can create a whole bunch, like creating harpoon, it's just actually wasn't all that hard, cuz most of it's just that they're available.

[00:04:31]
The hardest parts was saving per location to a place that won't get deleted. That's in your local directory and some sort of data config, right? Just figuring out those things, like, how to, okay, you can't just have your project path, because file names are bound by a certain size.

[00:04:47]
You have to pass it through a SHA to be a certain way so it doesn't collide, all those dumb things, those are the hardest parts, using this to actually build it was the easy part. And so, it's pretty fun to be able to just hack and build whatever you want.

[00:04:59]
If you have an idea for a plugin, you can just go do it like, nothing says that I have to use this version of Git, but I can. You could make all this, all right? This just uses Git and it starts doing that. I've just staged all these changes.

[00:05:12]
I can start committing all those changes and do all that, they're just simple things, right? I did abort the commit, cuz it's an empty commit, you have to have a commit message. You can't just do an empty one, but you get the idea that all these are just created, and they're not that hard to do, some take more time.

[00:05:27]
This Git probably falls under to that real software line, you know the one I'm talking about that's not fun anymore? And so, that one goes there, but Vim just allows you to do it. So this is the real reason why I continue to use it, is cuz of Lua, it's cuz I can edit my editor in a simple language that scales fairly well for small to medium-sized projects.

[00:05:44]
It's probably not a great language for large projects, but it's good enough that I can do anything I want. And so, there's kind of my case for why it's fun to do stuff, I had this one where I had this little example code. This will just open up a little window that will be relative to the editor, that'll be kind of big, that will read in any file and then print it out.

[00:06:00]
So I could just say, instantly have your package.json pop up as something you can look at and edit, and then close it back down. Right, you can just do fun things like that, not that that's useful, right? You can just fuzzy find package.json, but theoretically, you could build anything you want that you think is cool.

[00:06:17]
And so, one time I had an Arduino and so I was writing a program to it, right? But it takes a little bit to start, and then it start, and then it start doing something, and then it pipe out output. So, and then I had, all my debug output, so I just wrote something that did system tail file, this file that is the file descriptor for the Arduino.

[00:06:34]
And then I just had that as a floating window in my Vim, so I'd just be programming, send it. It's okay, I can see it loading. Okay, got the files. Okay, it's starting to print these things. Okay, I like that, I see what I did wrong, and then I could just go back and forth, cuz I could just build that window in just a couple lines, follow something in a couple lines, and just run it once.

[00:06:51]
And so, it's a very hackable experience, which I think makes it super fun. So that's why I like it. There's a lot more, hopefully enjoy that. And a quick note about AI, you can pretty much just ask any of the AI's cloud, to make you a plugin and it would just do it pretty much one shot every time.

[00:07:09]
It's just because the APIs are so well documented and they're always so hungry for human-generated data that they've just gulped up the Neovim API like 9,000 times. So they have a pretty good, strong correlation with it, so it mostly will produce good stuff. It may use slightly older APIs as opposed to newer ones, or do things in a little bit wonky way, but it can pretty much make anything every time, and so, it's pretty nice to do that.

[00:07:34]
Also, I made a little game, it's called VanBeGood. So if you go, VinBeGood, someone just added this. If you wanna get good at basic motions, you can do something like a relative, you delete whatever line you wanna play, and then it's gonna show you this. And so, you can go like five up, delete me, seven up, delete me, three up, delete me, one up, delete me, 17 down, delete me, right, three up this.

[00:07:56]
And then you can just go through and it'll just do, what, 12 of them. There you go, and it shows you I got an average of 13, all that, yay, right? That was pretty good, and it has other games in it. Someone just added this just last week, you can play a little game of snake, which is actually, it's really, really hard to play snake.

[00:08:17]
They didn't normalize the speed going downwards versus going sideways. Fundamental game design flaw here, but you can see that it goes really slow, and then speeds up really fast, right? And so, you can kind of see this game. So you can like learn how to do H, J, K, and L, all that kind of stuff, so it's actually pretty fun.

[00:08:31]
There you go I killed myself, all right. Nice, there you go, that is the funnest that's available, it helps you learn. Actually, the reason why I got good at relative jumps, the reason why I created this game is cuz I could never get into the habit of using relative jumps.

[00:08:49]
So I was like, there's only one way I can get into the habit. Is I have to build something that optimizes a reward center for me to be able to use it. So I built the video game just so I can hop to it and get so used to it, that now I use relative line jumps as just like my daily mode because of that.

[00:09:03]
So then, that's just stop optimizing things. This last part, this may get a little bit offensive. This is about terminals, I don't really care what terminal you use. I know a lot of people feel that this is the section I said this earlier. A lot of people, I told you I was gonna have to say this again, but a lot of people feel very near and dear to the technology they use, they're absolutely married to Kitty or whatever.

[00:09:24]
I'm not, I use Ghosty because I like Mitchell, right? That's as simple as it gets. And so why not Alacrity? I was using Alacrity. Why not Kitty? I don't use Kitty because I don't, I find the person who wrote it to be unpleasant. He says very mean things on the Internet to people, so I don't like him.

[00:09:40]
I don't wanna use this stuff, Ghosty, he's very, very nice, I used to I used Xterm-256color up until this year, I used a terminal from the 80s for almost my entire programming life. Like that's just that, and it's just the only reason why I switched is because I couldn't play ASCII doom in my terminal, and anything larger than a small ask amount, and I need it to be pretty large.

[00:10:02]
And so, that's the only reason why I switched. Unless if you're using Westerm, since you can build the entire TMUX experience or ZelleJ experience, they're inconsequential to me. Other than that they exist, they're fast, and they work, that's all I want. Give me fast, it exists, and it works.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now