Check out a free preview of the full VIM Fundamentals course

The "Recap" Lesson is part of the full, VIM Fundamentals course featured in this preview video. Here's what you'd learn in this lesson:

ThePrimeagen discusses previously covered navigation, vimRC, and file navigation. Student questions regarding how to change cursor thickness and multi cursors are also covered in this segment.


Transcript from the "Recap" Lesson

>> All right, so let's keep going. So I've showed you the Jumplist. I've showed you Alternate file. It's pretty cool, right? There is a lot of navigation that is available. But none of that is quite as good as a fuzzy Finder. So we probably need to do something about that, right?

But before we do that, we are going to take a quick pit stop right here, just kind of talk about everything to kind of go over all the things we've learned, right? If anyone has any thoughts or questions about just like general motion navigation, meaning within a file.

Anyways, so one thing that always kind of was hard for me at first was just hopping efficiently between the modes. One thing I would recommend is you can try remapping your capslock key to Escape. I've heard people like that a bunch. So being able to switch really quick out has been fantastic.

So I started using Ctrl + C to swap out, because Ctrl + C was really nice. It was really easy. A common one that I see all the time were kind of in the rift zone right now. So, we're riffing. So who knows what's gonna happen out here?

All right, I'm gonna edit this and I've seen this all the time. I personally don't like it, but I know people like it. So Glinoremap,.jk, and then go, <esc> Ctrl + c. All right, that's it. So, I'm gonna remap jk while in insert mode to actually become the Escape key instead.

So, let's just shout it out. I could type that or I remember I can just do space + Enter. Boom, did it. Now I'm over here typing then I go, jk, I'm out. I'm back into normal mode, right? So I have now made it into what I want.

Some people use jj. So that way, I wouldn't suggest jj. Abrams, that's way too long. But one thing that's nice about that is you can just start scrolling, right? And it will just start doing it for you. But notice that you get that weird offset. It's why I don't like it is when you type a j.

It like trips me up for a second because the j appears after my cursor and I'm like, my brain just can't handle that. That's why I usually don't like those type of remaps. And it also feels funny. I like to just try to use as many default vim bindings as I can, unless if they're terrible.

And so, executing Vex, I'm fine having that as a remap, because that's just a command. I type it in, it's slow. Or I can make it into my own personal one. But Escape is just Escape or Ctrl + c is just Ctrl + c, I can get used to that, right?

And so that's kind of my general approach there. All right, the Vim RC. So we do know a little bit about it. We do know that Vim will, that language we're using to describe the changes to our Vim RC and what we want to have happen. It's kind of ugly.

Okay, we can all be honest with ourselves. It's a weird looking language. It has a lot of Vinism built into it, cuz it's a language for an editor. It's generally pretty hard to learn. And there's, it only has one use case, making them stuff, right? And so I know a lot of people that just tend to avoid it.

I recommend learning enough. Is there any, I don't think there will be any questions about what we've done so far, but if there is, please throw it in the chat. I hear your five seconds delayed or speak now forever hold your peace inside of the Zoom meeting. But here's the deal.

Don't be asking questions that haven't existed yet. Someone's gonna be like, well, how do you make functions? I'm like, no, no, no. There is like a gy cursor somewhere or another I forget exactly what it is. I have it in mind enrc horn Vex enrc. Sorry, we don't have any of the, I don't have any my normal navigations open right now.

But if I'm not mistaken, it's under my sets, gy cursor equals, so I'm gonna take that, I'm gonna yank it into a special register. As you can see right there, I did an extra couple commands. And so now I should be able to do that, awesome. So now let's Vim this and I do, no, where to go?

Anyways, I think it was said gy cursor. I believe that's the one I did. So let's shout that out. Now when I go into insert mode, it remains thick. I actually really liked the thick looking cursor. It's just like something I've gotten pretty used to. Some people don't like that at all.

I don't know why, it's just like super comforting to me. Yeah, I just it's so great. Anyways, there you go. I hope that answers the question. I kinda guessed a little bit what that question was meaning, but anyways, there we go. So there are so many things. You can also, like I said just google it cuz who would have guessed gy cursor, right?

And if you would have opened up a help options, and then started typing the word cursor in, trying to look for the word cursor, you're gonna just be, I don't know which one to do, right? It's just way too many options. It would have been very very difficult to find it.

You could have also done help cursor and then tried to like tab completed. Maybe you would have found it. You'd have to guess which one it's gonna be. But as you can see, there's just so many options, right? I saw one that said parole, that sounds dangerous. I just stay away from that at all costs.

All right, final navigation. So, there's some options, marks are pretty awesome, but they're hard to use file tree, bit lacking, right? You kinda wish you had some extra features in this file tree. But that telescope, was that a pretty cool fuzzy finder? The best part about that telescope one is it's not just simply a file finder.

You can pipe any table, any list of entries to it. It can fuzzy find, it can send a quick fix list, it can do a whole set of things that you can keep on iterating on it, and it can even hold state. You can also have your own custom remaps with it, it's actually quite incredible.

All right, we got two questions. It looks like, or just two fingers up for one question.
>> Is there a way to do multiselection in Vim?
>> So multi cursors, I assume this is what we're talking about. So there is a couple ways you can sort of accomplish that in Vim multi cursors, is always one of the, just the chief questions.

I am gonna throw this out there that I know, I'm gonna get some, gonna catch some flack for it. I'm ready. Multicursors are an anti-pattern. They solve a particular problem and you often have to shoehorn other than like say simple renaming. Simple renaming you can do a find and replace.

You can also execute macros over it. There's also a G command that's incredible with it, where you can actually execute whole set of editor commands on matching patterns. Anything that involves you selecting things like that I just feel is it's always most, it's there for renames, right? But anything complex, it completely breaks down.

Say you wanted to take an if statement and switch it into a case statement using cursors would be terrible, cuz you'd end up like writing over some of it over here because you have to use a specific amount of editing. And so that's why I've never found them to be like the real solution.

They're just a simple solution that works 80% of the time. So we're gonna cover macros here soon, and I'll even go over the G command a little bit. It's a little crazy, but it is definitely what I would consider the better of the two options.

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