Hello the beautiful people.
And welcome back to our discussion of how to use the nano command line text editor to get your work
done.
So we were in the last video, we were discussing some of the options that Nano has and we discussed
the write out option, the read file option, the where is option, and we got up to the replace option.
So let's actually use the read file option to read in birthday text again.
So we're going to say birthday dot text and you can see that we've got happy birthday read into the
file once again.
And the reason I've done that is so that we can now use the replace command.
And you can see here that the replace command or the replace option here is activated by pressing control
and a backslash.
Now I find the backslash next to the letter Z on my keyboard, but it might be wherever that is on your
on your computer.
On your keyboard.
Okay.
So I'm going to press control and backslash and now it's asking me what I want to replace.
So let's replace birthday and we're going to replace it with code day.
And when I press enter, it's going to now go through each instance of where it found the word birthday
and ask if you want to replace it.
Now you can see down the bottom here, it's going to say, you want to place this instance?
I could say yes, I could say no or I could say all or I could say control and C for cancer.
So let's just press A to make it replace all.
And we see that every instance of birthday has been replaced with the word code day.
So happy code day to you, you beautiful person.
So that's a replacing text.
What about cutting text?
Cutting text is the next one.
So cutting is very easy.
You can see here we've got this line that says Happy Code Day.
If I press control and K to cut that basically deletes the line and if I want to paste that.
So basically it's just like cutting and pasting just in your normal everyday computer use.
So if I want to uncut it, I press control in you and I can do that as many times as I want.
So this is a very, very happy code day.
We can also justify the text using control and j.
So if I press control and J we'll see that the text has been set so that it takes up the full width
of the screen so I can press control in you now to unjustified.
But you can see if I press control and j to justify the text.
The paragraph that I'm in takes up the full width that it can text the full width of the screen.
And for press controlling you, I can justify it.
So that's something to bear in mind.
If you look at control J is justify and before you justify control u is uncut text.
But if I press control and j you see that controlling you has no switch to earn justify.
It tells you here you can now unjustifiably press controlling you.
It goes back to the way that it was.
So up next, we've got the two spell option, which is basically a spell checker.
Now, by default, a spell checker isn't set up for Nano.
So if I press control t it'll say spell checking, failed error invoking spell.
Okay.
What that means is that there's a spell checker not actually set up, but we can set one up.
So let's just save our file by pressing control on O to write it.
Yes, that'll do.
And then press control X to exit and clear the screen with control and l see a lot of keyboard shortcuts
going on here.
So to actually edit the text, the sorry, the spell checker that is used for Nano, that's in the nano
configuration file, which is actually located in our Etsy folder in a file called Nano.
RC So let's open that really ironically with Nano.
So if we do that, here we are, we've now opened our Nano.
RC So it's slash ETSI Slash Nano.
RC So if I show you that graphically where, where we're going, we are in our base directory by going
to other locations and computers.
So this is the slash folder, then you go etsi, so slash etsi, then somewhere in here there'll be
a file called.
No, no, no, no nano RC There it is.
So if we click on Nano.
RC That's basically what we've opened, but let's make sure that we open it in in here.
Actually, at the minute this file is in fact unreadable because we don't have the permissions to edit
it.
So to make that actually editable, we need to do sudo nano slash etsi slash nano RC.
So this pseudo bit basically allows you to run this command as the administrator, but we'll come onto
that a bit more later.
In the course.
You enter your password that you normally use for logging in and now you can edit the file.
Now there's a line in here that has the word a spell or spell in it.
So let's find that by using the where is command.
So let's use the.
Where is Aspell?
Press enter and it found it.
So this line it says here, use this spelling checker instead of the internal one.
This option does not properly have a default value.
So to get rid of that, actually, to make that actually happen, we just need to get rid of this hash
symbol and get rid of the leading space.
So now there's no there's no hash just set speller aspell dash, x dash.
See, just like that.
Now, if we write out and close and now if we go back into Nano for our diary dot text, if we press
control in T to actually start the spell checker, we now have a spell checker working.
So isn't that quite cool?
Right.
We just use Nano to edit Nano.
It's awesome.
So here we are.
It's going through our spell check and it's telling me my name is wrong.
Well, that's charming, isn't it?
But there you go.
That's how you can actually go about setting up your spell checker and you can just enter things in
here.
So if I wanted to change my name to, let's say Yoda, which of course I do, because that's totally
awesome.
I just enter five and you see that my name is now Yoda and it's a fact because it's on a video.
Okay, so if I now I can also close into any of these options.
You can ignore, replace, add to dictionary, replace all or ignore all or whatever it might be, but
let's just press X to exit and there we are.
We're back into normal stuff.
So once you've edited that, all you've got to do wouldn't you do that so that your spell checker works?
You're good to go.
And it is possible to to also add different dictionaries and stuff like that as well.
And you can find that information online as well.
Okay.
So there we are.
That's how you do spell checking and a control in C is apparently tells you your current position.
So if I press control and C, it'll tell us I'm online one out of 19 5% of the way through column one
out of 17 and character zero out of 275.
So if I move over here now and I press control and see, that will change.
I'm now on line seven, column ten and stuff like that.
So this is this is good.
If you are working on a file and you want to give it to someone and you say, Oh, hey, can you change
this file at this given position?
Or you're giving people instructions on how to use a file and you say on line seven, in column 11,
change this text.
So, in fact, just to show you let me let me actually save that.
Yes.
If I go to edit our slash etsi slash nano RC file and I can search for where is that a spell?
Now, I can tell you here we are.
I'm on a spell.
And if I press control and see, I can see here that I'm on line 172.
So if you want to set your spell checker, go to line 172.
And that's the line that you need to edit, for example.
That would be one way to do it, right?
So I can close that, get back into diary dot text.
Now we're getting through.
The next option is control and underscore and that allows us to go to a line.
So if I press control and underscore and press control and underscore, oh, sorry, I'm pressing the
wrong button here.
Oh, there we go.
Because underscore is in a bit of a weird position on my computer.
So I press control and underscore and it says, enter the line number and column number.
So let's go to line ten, column two.
And there we are.
I'm in line ten column to see if I can actually get this stuff to get a bit bigger.
There we go.
I've made the font a bit bigger.
So Control Underscore done it because I have to press control and shift and underscore.
There we go on mine anyway.
So so now you can enter a line number and column number.
So let's say line nine, column 12.
There we go.
We are in line nine, column 12.
And columns aren't separated by spaces.
They're separated by letters.
Okay, so here we are.
Here's column.
One, two, three, four, five, six, seven, eight, nine, ten, 11, 12.
And that's that's where we this way we might get to if we went to column 12 on whatever line.
So if I said to you, let's edit our slash Etsy slash RC file and I looked for using using the where
is command I do control W and I search for a spell and I get to this line.
I'm like, ha, where is this line control in C which is current position.
It says line 172.
So now on your computer, when you open the file, you be like, ha, z says line 172.
So press control and underscore enter line 172 Press Enter.
And I've ended up at the correct line, so you can see how useful that might be if you're collaborating
on something with someone.
So let's get back into our diary text.
We've then got undo and redo.
So if I for example, cut out all these things here and then I was like, Oh, I don't want that to
happen, let me undo.
You can see I just undo and it undid all those delete things.
I could also press alt and E.
And remember, this could be escape or command depending on your keyboard layout, just the modify key,
whatever that is for you.
On my keyboard it's alt, but if I press alt and e that should redo alter new undo redo oops.
Alternate E alter new.
Yeah.
Yeah, I've broke it now, but you get the point.
So, so that's how you can undo and redo stuff and instead of cutting because you see here, if I cut
now I can uncut instead of cutting you can actually just directly copy.
So here you've just got to do alt and the number six.
So if I press alter the number six now I can press control and you and I'll start pasting.
So maybe if I, if I do it here alternate six and then press controlling you, now I'm copying and pasting
just like that.
So that saves you from actually cutting and mark text as far as I've seen or I don't use that one very
often, but as far as I can tell, all that does is allow you to highlight stuff.
So yeah, just it just kind of allows you to highlight stuff.
So there we go.
That's basically everything you need to know about using the nano command.
So there you are, you beautiful people.
In the last couple of videos you've become very familiar with using the nano command line based text
editor.
Now, the benefit of using a command line based text editor such as Nano is that you can get all of
your work done without leaving the command line, which basically maximizes your productivity.
It command line editors have lower resource requirements than graphical equivalent, so you don't need
as much hardware usage in order to actually run them.
And also, if you were remote administering something like a server, the techniques you've learned
here would still work because Nano basically comes with every version of Linux, at least the most common
ones anyway.
So you've learnt how to use Nano and we've looked at a lot of keyboard shortcut options and you saw
how to use pretty much all of those.
So you don't have to memorize them.
Don't worry about that.
Now you've got a bit of an idea about how they work.
Honestly, Nano is just a text editor.
You can just type text in there, you can write code in there, whatever you want to do.
You can edit files in there, but just bear in mind that the tools, the options in there are accessed
using keyboard shortcuts.
So if you see this little hat, then that means the control key.
And if you see M minus, that's either the alt escape or command keys on your keyboard depending upon
your layout.
Just try them out.
See which one works on your keyboard layout.
On mine it was alt.
It might be different on yours.
And you also saw that you can edit how Nano works by editing its configuration file, which is located
at slash ETSI Slash Nano RC.
So a lot of this stuff is going to be probably for reference for you.
So you've got it here in this video, in this course to refer back to later on if you ever want to look
anything up.
But really nano is very simple to use.
You just type nano, then the command, then the file name that you want to edit and you can just go
and edit it like any other text file.
So there you are.
You now know how to edit files from the command line.
It should be feeling quite a lot more like a computer wizard at this point.
So with all this super awesome file creation, moving, copying and pasting and editing that you'll
be doing, it's possible that you might want to find where certain important configuration files are
located so that you can edit them or wear that file that you created has run off to.
But you don't want to have to go through each folder manually to look for them.
So in the next video you're going to learn how to search for files anywhere on your system using the
Locate Command.
Now, the Locate Command is one of my favorites and I can't wait to show you.
So for all that good stuff, I'll see you in the next video.