 Hey what's up everyone, so in this video we're going to talk about spell checking and dictionaries in Vim because a lot of people comment on my video saying, okay Vim looks really cool, can do all this stuff, I've heard great things about it, but I really, really, really need a spell check. That's why I use Word, that's why I use Google Drive, that's why I use whatever Libre Office, but the fact of the matter is you can be excused for thinking that, because Vim doesn't wear its features on its sleeve, but Vim does in fact have a spell checker, and it's actually really nice, it's totally built in, don't have to install on anything fancy, it's already in your Vim if you have one, so in this video I'm going to tell you the basics about it because it's really extensible, there's some really cool things you can do with it, so anyway let's just get into it. So here I have a document just a random document, this real life document that I wrote, I just threw in a couple extra spelling errors, so we're going to use spell check today. So to activate spell check in Vim, all you have to do is go to your command mode and type in set, spell, and then exclamation point, and run that. So when you run that you are going to see that a bunch of words have now been highlighted. So before I talk about those, let's talk about the words that weren't highlighted. So if you run up here, of course, you know, you have, you know, all these words that are in the syntax, so use package is not a word by itself, so Vim, you should notice that Vim is pretty smart at knowing what is syntax, like what is, you know, LaTeX or Python or whatever else, and what is actual text. So it knows that this stuff is text, so it actually spell checks all that, it's not going to spell check, you know, make title or something like that. Now that's not true, Vim is pretty good at LaTeX, which is what this is, it's not as good with other languages, but just notice that it does do that, it does ignore things that it knows are syntax. So anyway, you'll notice that some words have been highlighted. So actually, I should note something else. So let's say I have standard dies, right, so that's the American spelling, and here is the British spelling. So by default in my machine, I just have, or by in Vim, I only have the default English spelling, which happens to be, I guess, British spelling. So you'll notice here that if you put uniquely regional spellings, like here, standardize is spelt in the American way, it will also underline those, they won't be highlighted. Now these words here, which are highlighted, are misspelled, but Vim also has regional spell checkers. So this I should have, I didn't actually notice until I type these in that I'm on British spelling, but maybe I'll change that. But anyway, so let's talk about the individual words that are misspelled. So of course you can go to each one and change them the way that you might normally change a word in Vim. But of course everything is built in, you don't have to press a bunch of buttons to get to the right word or something like that. So what you can do in Vim, let's say I'm up here, is if you want to get to the next misspelled word, let me turn on screen key, you just type right bracket and then S. So right bracket S, now I'm on standardize, right bracket S, now I'm on narrowly, right bracket S, now I'm on language, et cetera, et cetera. And as you might expect, left bracket S, it goes backwards. So if, so that's that. In addition, if you only want to look, let's say I don't really care about these regional spellings, if you only want to look at things that are actually really bad, you can skip to them by bracket and then capital S. And that's going to skip over standardize. So watch in case you missed it. So if I press bracket S, I go to standardize. If I press bracket S, it goes past standardize to narrowly. So that way you can skip to the kind of words you actually care about. Who cares about regional spellings? So anyway, you can go to these again and just, you know, type them out the way you normally correct things. But even that is too, it's too many key presses for Vim. So what you can do is when you're at a word, if you want Vim to give you suggestions for auto correction that you don't need to actually type in yourself, you just type Z and then equal. And then Vim is going to bring up this little menu with all the kind of words that this word sort of looks like. In fact, it is even so nice to even give you multiple word suggestions in case you smush two words together. So all you have to do is select which one you want. I'm going to pick one. And that's that. So you can go to each of these and, you know, just Z equals them. And, you know, put them in as as you come to them, right? So I'm going to go ahead and do this because actually, I'll do it after video. Who cares? Okay, so I'm going to talk about other languages in a second, but I'll skip to one other point before. So what if you want to add words to your dictionary? So if you look here on this line, I have this word Chomskian, which is highlighted as being wrong. Now this is the correct spelling of this word. It's not a very common word is a word based of course on a name. So it's not, you know, it's a word that I have to use in my work a whole lot. But sensibly, it's not in VIMS dictionary. Let's say I want to add a word to VIMS dictionary. Well, it's actually super easy. It's literally two key presses. All you do is press Z and then G. Now Chomskian is now in my dictionary. And you'll see that this other example is no longer highlighted as well. Let's say I change my mind. I'm actually like, you know what, that's a word I shouldn't use. Maybe I should be saying generative or something like that. I don't really want to say Chomskian. To undo that, to undo ZG, you just type ZUG. So ZUG. And now Chomskian is back as a bad word. So one little note. VIM actually has two word lists. It's a little confusing how this works. Or custom word lists at least. I'm pretty sure, you know, global word lists as well. But when you use ZG, what you're doing is you're taking that word and you're putting in a list that VIM is looking at to say these are always good words. So that's your good word list. There's also a bad word list. And you can put words on that. And if VIM sees one of those, it always says that's a bad word. So let's say traditional. For whatever reason, I'm like, I don't like that word. I'm going to put it, you know, mark it as being misspelled or something like that. So I don't type in. Well, so to make that a bad word or a wrong word, you just type Z and then W. Now, every time I type traditional tradition, you'll know it's going to be marked as misspelled. Okay. So as you might expect, so right, ZG is add a word to the good words list to take it off Z U G Z W is added to the wrong word list to take it off the wrong word list as you might expect Z U W. Now it's off the wrong word list. So do be careful with this because you don't want to have something. VIM gets a little confused if you put a word on the good list and the bad list. It'll it might mark them sort of it might change what it marks it as as you move around. It's really weird. But yeah, just make sure not to do that. So the last thing that I think is worth talking about, which I definitely use and probably other I mean, I have so many people who watch this who, you know, are multilingual or, you know, study other languages. So you'll see here that I've added a sentence in Spanish. So sensibly, it's actually not just Spanish. It's Spanish and misspelled. So it's even worse. So this is a so what if I want to use a different language for, you know, when I'm spell checking? Okay, so if you want to do that, all you have to do is go to I have to actually think about it for a second. Hold on, I took notes. See, I have all this stuff on VMRC. Okay, yeah, yeah, yeah, set spell lang, that's three L's in a row equals and then whatever language you want. So I'm going to choose Spanish and Spanish's language code is yes. So I'm just going to run that. And you'll see all the English stuff has not now been marked as bad. And Spanish, of course, is the language we're now testing for. And but we can now clearly see our errors in Spanish. And just like in English, we now can use autocorrect and stuff like that. So I can say Z you. And this should be number nine. Right, or, you know, go to why am I using W? I should be using the actual built in function for it. Silly me. So you can just as easily use this on any other language and replace all the words. Why am I actually doing this like a serious correction? I don't even need this. I just added this in. So anyway, you can pretty much add languages in as simply as you want. If you don't have the language as dictionary already downloaded, Vim will actually prompt you do you want to download this languages dictionary or something like that. So if I say, you know, set Lang to FR for French, which I think is French's language code, it'll ask me if I want to download it and it will after a second. Okay, there it goes. Yeah. So it will also ask you where to save the file, just say one for the default location. And I do also recommend having a suggestions file for easier auto auto correcting. Just say yes to that when it asks you. So after that, you'll have another spellchecker. So how do I easily switch between using them? So putting in the all the commands is one thing. But of course, I have to have everything mapped to one or two keys. That's just how I am. So if I open up my VMRC, you'll see what I do. Let me make this a little bigger. So what I do is I map to F six this command. So this is going to say basically turn spelling on and also set spelling to English US English. Oh, that's why yeah, that's why it wasn't checking for US English before because I just typed in spell. But if you put you specify the language, it's going to specify specifically that. So that's to actually turn on spelling or turn it off. If it's turned on, I also have it. So if I press F seven, that just changes the language to Spanish. So this will check it as if it's Spanish. So that's pretty much how I put it in. You can check this out yourself. Just copy it. But it's pretty straightforward, pretty simple. So this video, this video went on longer than I expected. But this is all you need to know. Actually, there's probably more. I don't want to say that. But this is all the basics of dictionaries and spell checking in VIM. They're excellent. They're keyboard accessible. They're fantastic. So check them out as usual and I'll see you guys next time. Hope you learned something.