1 00:00:06,719 --> 00:00:08,269 So why do we need text editors? 2 00:00:09,470 --> 00:00:15,470 Well, working in Linux mostly happens from the command line, and that means that you need a command line text editor. 3 00:00:16,690 --> 00:00:21,050 Nano is easy to use and available on many Linux installations by default. 4 00:00:22,649 --> 00:00:27,769 Even stronger, it has become the default text editor on many Linux distribution. 5 00:00:29,100 --> 00:00:33,380 But if you really want power and advanced features, you should use vim. 6 00:00:34,000 --> 00:00:35,740 VIM is VI improved. 7 00:00:36,509 --> 00:00:40,670 That's a very powerful editor with features that you won't find in Nano. 8 00:00:41,509 --> 00:00:48,213 That's also why I would recommend you learn how to use VIM also, because on some systems you will only find 9 00:00:48,213 --> 00:00:54,916 VI for the simple reason that VI is a minimal editor. It has been around for a long time, and that 10 00:00:54,916 --> 00:01:01,619 is why you might find yourself behind a system that does not have Nano, but it does have vi. 11 00:01:03,039 --> 00:01:07,920 Now, the bad thing is that VIM is more difficult to use, but you should learn it anyway. 12 00:01:08,879 --> 00:01:11,840 It's always available, even on very old Unix systems. 13 00:01:12,500 --> 00:01:16,750 It's powerful and programmable to perform text file operations in an easy way. 14 00:01:17,310 --> 00:01:21,365 And if you want to set your favorite editor as 15 00:01:21,365 --> 00:01:25,420 a default, you can use export editor is $with Vim. 16 00:01:26,650 --> 00:01:27,390 I'll demonstrate. 17 00:01:29,269 --> 00:01:32,109 So let me first show you how to work with Nano. 18 00:01:33,129 --> 00:01:39,329 Nano, my new VAL that's opening my new file. And the convenient 19 00:01:39,329 --> 00:01:45,530 thing is that I can just start typing. Hello, Start typing. 20 00:01:46,409 --> 00:01:47,530 How are you? 21 00:01:49,709 --> 00:01:53,959 Even if it's just a demo, let's do it without any errors. 22 00:01:54,560 --> 00:01:59,609 Now, the nice thing about Nano is that in the lower part of the screen you see all of your controls. 23 00:02:00,689 --> 00:02:07,305 So the control that I'm going to need is control X, Control X for exit. But you can also 24 00:02:07,305 --> 00:02:13,920 find using control F or replace using control backslash and more in the controls on the lower part of 25 00:02:13,920 --> 00:02:20,535 the screen. If it starts with a caret, the caret is a control character. And if it starts with 26 00:02:20,534 --> 00:02:27,150 an M, the M is the metakey and the meta key is typically the alt key on your keyboard. 27 00:02:27,860 --> 00:02:33,039 I'm going to use control X to write my file and then it's asking save modified buffer. 28 00:02:33,590 --> 00:02:38,769 That means that all changes in the file are currently in memory only and 29 00:02:38,769 --> 00:02:43,949 only when I've committed them using Yes, I have saved my modified buffer. 30 00:02:44,750 --> 00:02:48,775 It's asking for the file name and the file name, my new 31 00:02:48,775 --> 00:02:52,800 file. That's okay. So I'm entering and then we are done. 32 00:02:53,800 --> 00:02:59,360 Now how do we do that with vim? Well, I will show you later, but the first thing that 33 00:02:59,360 --> 00:03:04,920 I want to show you is how to make sure that you use VIM as your default editor. 34 00:03:05,500 --> 00:03:11,996 That would be by using export editor is followed by dollar width vim and what will that 35 00:03:11,996 --> 00:03:18,493 do? Well, that will make sure that if ever I'm using a command that needs an editor, 36 00:03:18,493 --> 00:03:24,990 it will use vim as default editor and that is how the world should be. 37 00:03:25,629 --> 00:03:31,106 Now if you want this to be persistent then even 38 00:03:31,106 --> 00:03:36,583 make it a little bit stronger and use echo export 39 00:03:36,583 --> 00:03:42,060 editor is $which Vim greater than etc bashrc? 40 00:03:42,560 --> 00:03:47,780 I'll tell you about this later, but oh no, this is not working. You have any idea why? 41 00:03:48,300 --> 00:03:49,319 Permission denied. 42 00:03:50,300 --> 00:03:55,395 I don't have write permissions to etc bash RC and and I'm glad I 43 00:03:55,395 --> 00:04:00,490 don't because I'm using a single redirect which would have overwritten the entire bashrc. 44 00:04:01,430 --> 00:04:06,980 You need a double redirect to override in append mode and then I need to 45 00:04:06,980 --> 00:04:12,530 put this entire command between single quotes and I make that sudo sh c. 46 00:04:14,550 --> 00:04:20,436 If ever you have a command that has one of these shell metacharacters like pipes or redirects 47 00:04:20,436 --> 00:04:26,323 in it and you want to run the entire thing with sudo privileges, then you start your 48 00:04:26,323 --> 00:04:32,209 command using sudo sh c in this way and then it prompts for your root password and 49 00:04:32,210 --> 00:04:38,096 it just makes sure that this editor variable is also in the etc bashrc which is one 50 00:04:38,096 --> 00:04:43,983 of the startup files for the bash shell. I'll tell you in much more detail about that 51 00:04:43,983 --> 00:04:49,870 later, but for now it's already good that you have seen this convenient command at least once. 52 00:04:50,870 --> 00:04:53,079 All right, let's continue with the next video.