 Many Linux users are not comfortable using terminal-based text editors like Nano or Veeam. And I think that every Linux user needs to be familiar with at least one of these programs, if not both, because Linux is one of these things that you're often going to need to edit a config file, for example. And sometimes you're going to have to do this outside of a graphical environment. For example, say those of you that run Linux servers, you know, you got some web servers or something. Maybe that's an unmanaged server, so you're supposed to manage the thing yourself. You SSH into it, and maybe you need to edit some config files. How do you do that? Well, you're going to have to use a terminal-based text editor, something that you can edit text at the command line with. You're going to have to use usually Nano or Veeam. Now, of course, many of you guys only run Linux as a desktop operating system. You're not really interested in Linux on the server, but even if you primarily use Linux as a desktop operating system, you still need to know a terminal text editor like Nano or Veeam, because occasionally you will have to use them. Many Linux distributions, to get them installed, you have to install them from the command line, Arch Linux, Gen2, many server distributions, or actually command line installations, right? They don't boot into a graphical environment of any kind. So you have to edit config files. Sometimes you have to create config files at the command line. Even if you don't install those kinds of Linux distributions, those command line installations, you install easier to use Linux distributions like Ubuntu and Linux Mint and Mx and things like that that have graphical installers, right? Even if you use those kinds of distributions, sometimes you still need to use a text editor like Nano or Veeam, because occasionally you might break your graphical desktop environment. You can't even log into a graphical environment sometimes. And then what do you do? Well, you have to fix whatever the problem is and how you fix the problem is you have to drop to a TTY, a command prompt, and then at the command prompt, if you have to edit text files, you're forced then to use a command line text editor like Nano or Veeam. So it's very important to know how to use these kinds of text editors. Now, Nano and Veeam are two very different text editors. Which one is right for you? Which one should you invest the time in learning? Well, let's discuss this. Let me switch over to my desktop and I'm going to go ahead and open a terminal and I'll zoom way in here. And let me clear the screen and let's open something in Nano. I will open my Bash RC using Nano. And this is GNU Nanos. Now some of the history behind Nano is that it is basically an improved version of the old PyCo text editor. There was a text editor called PyCo that was initially released back in 1989 and then GNU Nano sprang from PyCo around 1999. The original Nano developer, he wanted basically a version of PyCo that was distributed under a free license because I guess PyCo wasn't considered free software back then. Anyway, Nano is essentially a very simple wissy-wig plain text editor. Wissy-wig, what you see is what you get. You just move with the arrow keys and you just start typing. You know, this is a line of text. It works like any other plain text editor you've ever used. If you've used notepad in Windows, right? Nano is very similar in function and feel. When I say it's a very simple plain text editor, I'm not just talking about it's simple to use. I'm also talking about simple and that it doesn't have any really advanced features. You're not going to find things that you find in more advanced text editors like Vim, which we're going to discuss. You're not going to have things like a window splitting. You're not going to have macros, auto completion. You're not going to be able to view multiple files at a time. You're not going to have vertical block editing and all of this cool stuff that Vim has. I may show you some of that stuff when I open Vim, but for the most part, Nano is just you move around with the arrow keys and then wherever you end up on the page, you just start typing. Now, let me quit out of Nano and I will show you Vim. So to quit out of Nano, there are some cheat sheets here at the bottom. It gives you some of the basic key bindings such as how to exit. You have control X for exit. The little carrot symbol is an alias for the control key. So control X and it's going to ask me, do I want to save my modified bash RC? No, so let me hit in and now I'm back at the command line and now I'm going to Vim dot bash RC here and this is Vim. Now Vim is a little different than Nano. The biggest difference between Vim and Nano is that Vim is a modal text editor, meaning it has modes. So you are not always in the same mode. Right now we're in normal mode and to navigate in Vim in normal mode, you use HJKL. H is the left key. L is the right key. J is down. K is up. So if I wanted to go down, I would hit J. If I wanted to go up, I would hit K. If I wanted to move to the right, I'd hit L. And these are the navigation keys. Now you could also use the arrow keys if you have a keyboard that has arrow keys. Vim actually, the reason it uses HJKL is because a little of the history behind Vim, it stands for VI improved because it is an improvement on the old VI text editor. The VI text editor dates back to the 1970s and when VI was created, many terminals, computer terminals, physical terminals did not actually have arrow keys on their keyboards. They use smaller keyboards and the HJKL keys on some of those old computer terminals actually served double duty. They were HJKL. They were also the arrow keys. So when you're in Vim and you're in normal mode, HJKL for the navigation keys get used to this because many, many, many programs in Linux actually use the HJKL motion keys because many of them try to emulate Vim motion. Now you're in normal mode by default in Vim. If you're confused about what mode you're in, just look at the bottom left and you'll see the word normal. The reason this is normal mode is because this is the mode you should be in most of the time. Anytime you're actually not writing text into the document, you should be in normal mode. So anytime you're doing a copy and paste, anytime you're just moving around the document, reading through the document, searching through the document things like that, you should be in normal mode. Now sometimes, of course, you want to add text. So maybe I want to add text on this next line here. I'm going to do J to get to this empty line to get into what is called insert mode, type I on the keyboard. And now you see in the bottom left, I have insert. That's letting me know I am in insert mode, meaning anything I type on the keyboard is actually going to appear on the screen. So this is a line of text, right? And now to get back into normal mode, I hit escape. And now I'm back in normal mode where hjkl would just be the normal motion keys. And of course, there's a ton of other keyboard shortcuts, such as w for word, I move forward by word, or b for back, move back by word, etc. Because VIM has these modes that nano doesn't have, it really makes VIM able to do things a lot quicker than nano. You're going to be much faster and more productive in VIM once you get used to some of the key bindings and some of what you can do with normal mode and insert mode. There's also several visual modes where you can select big blocks of text and then manipulate the block of text. But here in normal mode, if I wanted to go to the very first line, gg, I wanted to go to the last line, shift G, capital G. If I wanted to go to the fifth line of the document five, capital G, I'm on line five. If I wanted to delete a line, maybe I want to delete line two here, I'll DD for delete line. If I want to paste it, I'll go down to this line and hit p for paste. If I want to undo everything I just did, I just U a couple of times to get back to where the document started. If I want to search for something, I just hit the slash and then start typing the word I want to search for. Maybe I want to search for the word alias. And if I find the word I want to search for, I just hit enter and now I'm on the very first instance of alias where that string of characters appeared in the document. If I want to keep searching for alias, I just hit N for the next instance of alias. N again, N again, N again, N again. If I wanted to go in reverse order for the search term, I just do shift N and I will go backwards through the instances of alias that appear in the document. Now searching in Vim is very, very easy. One of the frustrations I sometimes have using nano is that it's a little stranger to search for things in nano. Let me on a second workspace open my bash RC in nano. So to search in nano, what you need to do is you need to do control W instead of just a slash. It's control W because again, nano doesn't have modes. So all the key bindings are more complicated. Most of them are going to involve the control key plus some other stuff because the control key is not usually used when you're typing text, right? So it can't use any of A through Z or the number keys. It can't use the shift key, which is used to capitalize things, right? The control key is kind of what is involved in most of nano's key bindings and yeah, that's a little clunky, right? That's not as easy and as fast to use as I just typed the slash key and start searching for something. Now I have to do control W and then search for something. I'll once again search for alias and if I hit enter, I will go to alias and now maybe I want to keep searching for alias. I want to keep moving the cursor to the next instance of alias where in Vim I just type in on the keyboard and normal mode. I have to do something more complicated again because nano doesn't have modes. The key bindings usually are going to involve things like the control key or in this case it's going to involve the alt key. If I do alt W, I'll move forward to the next instance of alias. If I do alt W again, I will keep going to each alias. Some of the other key bindings in nano, control D will delete a character that's under the cursor. So if I did control D, I deleted the A and if I keep control D, you know, I can keep doing things like that. If I wanted to move forward by word where I just hit W in Vim, I got to do a control space here in nano. So you can do some of the same motion stuff in nano as Vim. It's just the key bindings are not nearly as easy and they're really not intuitive. For example, copy and paste in nano. I don't even know what those are unless I go to the bottom here and look at the cheat sheet because I don't use nano that often but they're control K, I guess for cut, and control U for paste. I don't know why they use control K and control U because nemonically, that really doesn't make any sense. So me personally, I've always found nano a little harder to use than Vim actually. Let me move back to the workspace where I had Vim on and of course that was just showing you the differences between nano and Vim as far as basic movements moving around the document and doing a search. Now Vim obviously has many many more advanced features that nano just doesn't have. So I'm going to gg to get back to the top of the document here and I'll do zero to get to the beginning of that line. Again, we're in normal mode so all the keys have different functions here. Zero always gets you to the beginning of the line, dollar sign always gets you to the end of the line and Vim. One of the cool things that Vim has is visual mode. So if I did shift V, which is a visual line mode, I just hit J to go down. I'm going to select this entire block of text here. These seven lines which are just comments at the head of my bash RC. I've selected them now. What I could do is type D on the keyboard for delete and then I'm going to type shift G, capital G to go to the last line. Remember that? Then I'm going to hit O to create a new line and then what I'm going to do is I'm actually going to escape to get back into normal mode because O put me into insert mode but now I could hit P for paste and I just pasted those five lines here in Vim. Another cool thing you can do in Vim is global substitution. So I'm going to go back to the first line here and what I'm going to do is maybe I want to search for every instance of alias and replace it with a different word. Well you can do that by using command mode. Command mode is type the colon and now enter a command. What I'm going to do is percent S for a global substitution. I want you to find every instance of the word alias, the string of characters alias and I want you to replace it with alias all caps and then slash G. We're going to make this a global substitution and if I hit enter it found 82 instances of alias or lowercase and it replaced it with alias now all caps. Command mode makes Vim really powerful because you can really get some complicated stuff going on here. If I wanted to do another substitution what I could do just for sake of demonstrating how cool Vim can be. This time I want to substitute the beginning of a line so I'm going to do the carrot symbol that's regular expression that's basically symbolizing the beginning of each line and what I want you to substitute the beginning of each line with? Well I want you to substitute that by running this command here. We're going to do a print f and then I'm going to do a single quote and then I'm going to do a parentheses dash 4D, single quote and then a comma, and then I'm going to do line and then in parentheses, single quote, period, single quote and then the ending parentheses there. What this command is going to do. It's going to add add line numbers to the beginning of each line. So it's going to substitute the beginning of each line with a line number, whatever line number that happens to be. It's going to print it. And it's actually going to insert it into the document. So if I run that, now we have line numbers. These are not the visual line numbers over here, which are not part of the document. It actually inserted line numbers as part of the document. So if I gg to get back to the top here, you can see one, and then it goes all the way to line 270. Maybe I want to reverse the order of the lines. Maybe I want everything in this document to be in reverse order. I could do that. I could do that with command mode. I could do colon g and I could do a slash. And once again, I could do the carrot sign for the start of each line. And then I'm going to do m zero. So basically, we're going to get a reversing order of the lines here. And you see now the very first line is line 270 and it goes in reverse order. If I do capital G to go to the last line, the last line now is line one. So that's a really neat command because occasionally you will find it's not something you run very often. But occasionally you may want to reverse the order of the lines in the document, explaining that command one more time. The carrot symbol, it finds the beginning of each line. And then what we're doing is m for move zero. It's moving the line to just after line zero. So basically it's taking each line and moving it to line one. So it took line one and moved it to line one. But then it took line two and moved that to line one. Then it took line three, move that to line one. So that's how you end up with this reversed order of lines here. Obviously you can't do any of this kind of stuff in nano. Nano again is a plain text editor, a very simple plain text editor, similar to something again like Notepad or WordPad or things like that, you know, those very simple plain text editors that many people are familiar with on Windows or if you've played with something like G Edit maybe on Linux, although I would say G Edit probably is more customizable and has more advanced features than nano. So which one of these text editors is the right one for you to learn? Because again, I think everyone should learn at least one of these text editors, if not both, because you will be required to use them at some point in your Linux career. That's just going to happen. Well, I think for basic use, let's talk about learning curve, just really basic use, meaning occasionally I need to edit some text in a file, a config file, and I just need to open a document, navigate through the document a little bit and then insert some text into it and then exit out of the document. Nano or VIM either one is easy to use for that and the learning curve, as far as the basics of these text editors, both are pretty easy to get up to speed as far as the basics. Nano has that cheat sheet at the bottom of it that gives you the key bindings if you need to know some of the key bindings. VIM actually has a built-in tutor called VIM tutor, all one word. All you need to do is open a terminal. Let me show you this. Let me get to a different workspace here. And if I open a new terminal and type the word VIM tutor, this is the VIM tutor. It's just a document that tells you all the commands in VIM, such as how to use hjkl. This is the very first lesson, you know, it tells you what the motion keys are. That way you can navigate through the document using the motion keys and then it gives you the next commands such as the x command here, which deletes characters. If I just press X or U to undo, you know, it gives you all the basics and it just takes you a step at a time what each of the keys does in VIM. You can actually read through the VIM tutor and go through the VIM tutor in about 20 to 30 minutes. The VIM tutor, it's actually not hard at all to learn the basics of VIM. Now, some of the more advanced stuff that you can do with VIM, such as some of the global substitutions you guys saw me do earlier in things like macros and regular expressions and things like that, that'll take a little bit more effort to learn some of that stuff. But even that stuff, the more intermediate to advanced stuff, you can learn most of this stuff within a few weeks. You can be very, very comfortable doing all of your text editing in VIM. So if you have really basic needs as far as text editing, you don't do a whole lot of writing, you don't do programming, you don't spend all day in a text editor, you know, which one to use, NANO or VIM, pick one for more advanced use VIM all day long, right? Because NANO is really, really limited as far as text editing. It's just a very plain basic text editor. So really VIM is perfect for programmers. VIM is also perfect for system administrators. And the reason I say for system administrators is you do system administration on Linux machines. Pretty much every UNIX-like operating system has VI or VIM installed by default on that machine. And increasingly you're seeing more people that do writing, creative writing, you know, they're using tools like VIM because it makes sense. VIM is a distraction-free way of writing. It is, of course, a terminal text editor, but it doesn't have all the bells and whistles and everything that a word processor has. So you don't, you're not distracted by formatting and things like that. All you do is you open up VIM and you just start writing, right? It's all about the story that you're trying to tell. So increasingly I see more professional writers using VIM. And one of the things that you sometimes see on Linux forms, Linux subreddits, is you see people that make fun of those that use NANO, right? NANO is kind of seen as the noob text editor. It's the one for beginners. And you're just not part of the cool club if you use NANO. You have to use something like VIM or maybe EMAX or, you know, something a little bit more advanced, right? More elitist, right? That's not the case. For those of you that want to take your text editing to a more serious level, then obviously you want to learn VIM. The VIM tutor, again, can be run through in about 20 or 30 minutes. You can be up to speed on the basics of VIM very quickly. Those of you that want to learn the more advanced stuff that VIM has to offer, you'll find a million videos out there explaining the advanced features of VIM. I've done plenty of VIM content on this channel, so do a search on my YouTube channel for VIM and you will find probably a couple of dozen videos probably I've done in the past explaining some of what VIM has to offer. Now, before I go, I need to thank a few special people. I need to thank the producers of this episode. Epsy Gabe James, Mitchell Paul, Wes Acame, Alan Chuck, Kurt, David Dillon, Gregory Heiko, Erion, Alexander Peacearch, Infador, Polytech Raver, Scott Steven, and Willie. These guys, they're my high-steered patrons. Without these guys, this episode you just watched would not have been possible. The show is also brought to you by each and every one of these fine ladies and gentlemen, all these names you're seeing on the screen. These are all my supporters over on Patreon because I'm sponsored by you guys, the community. If you like my work and want to support me, please consider subscribing to DistroTube over on Patreon. I'd greatly appreciate it. All right, guys. Peace. And of course, VIM is just a stopgap until Emax.