Hello, everyone, in this lesson, we will cover the Linux file ed and Ed is a program which enables
you to create and manipulate data or text in a Linux file.
There are several standard text editors available on most Linux systems you can use V.I. Eddys, Yak's,
Emax, Pekoe, and then which is at IBM, is the advanced version of B.I.
In our lesson we will focus on V.I..
Why?
Because V.I. is available in almost every Linux distribution, regardless of which Linux system you
log in and whether it's a Bunta Susi RedHat S.O.S, you're going to find V.I. everywhere.
Plus, it's very easy to learn that V.I. editor actually supplies commands for inserting or deleting
text, replacing text, moving around the file, finding substitute strings and cutting and pasting
text inside.
So that's what we does.
Then you have to write to a file.
The most common keys are I, which is to insert escape replacement for R D for the lead and quit without
saving and quit.
Right.
Let's say.
So let's look at our Linux machine,
OK, it's KDDI.
Who am I and which directory we are in in this directory.
I want you to create your first file.
So call it the AI, which is a common space of my first added to.
Or just say, my first of all, how's that much easier hit enter now when you hit enter, you are still
in command mode.
You are not in insert mode.
So there are two different modes.
Once you are in the VIP is first mode as to when you run the command.
Second mode is when you inside of the VIP and you start typing it.
If you wanted to get out of that typing mode, you have to hit escape.
So now let's start.
Let's see if I wanted to type into this file you hit I or insert lowercase I as soon as you hit I you
see at the bottom it says insert.
It means we are in insert mode now already a Linux commands won't work are we.
Because we are an insert mode.
So we could type something like Hello world.
This is my first lesson to learn by.
And you could hit enter again.
I am so excited about so it's just simple, as if you were taking a word document.
Now if you wanted to exit out of it, if you want to save this while all you have to do is hit escape
right here.
And once you hit escape, you'll see the insert mode is gone.
Now, how do you save this file?
You could do it through two different ways.
One, you hit shift a Z.
The the twice, and it will save the file.
Let's see if you do cat again and do my first file, you'll see it's there another way to save a file.
Let's go back in the file, Mike, first file and let's say you want to type something
hit insert again and then high space and now you want to exit out and save hit escape.
And this time, instead of shift, you type shift Callon right quick and exclamation point, which is
also referred to as bang, you hit enter.
How do you verify you read the file.
My first file and there you go.
The file is there.
So this is these are the two modes is once you get out and once you get in.
Now I want you to go back into your file and it V.I. and my first file and I want you to replace.
Hi now I want you to delete.
Hi.
And leave that as is now.
How do you go move around inside of a file then you are already in the editor.
You could use up bottom left right keys on your keyboard to move around.
But remember, you cannot use these keys if you are in insert mode.
So let's say if you are hit I and you now insert more and now you do up left right key.
It can work but it most likely it will break your command.
So it's better you hit escape and go back and then you do D on your keyboard D.
This will delete.
The entire line I wanted to delete only the void, hi, so how do I get back my last line that I deleted?
So you hit you just simple you and it brings back your last line.
Now, if you wanted to remove the high just type X once, which would remove one character type X again,
we should remove another character.
Now you have a space hit X again.
Now you don't have a space.
Now what if you want to save now again, do shift twice and it saves it.
How do you where fight you do cat my first fire and it is there.
Now let's go back in again and let's practice the replace Command VII.
My first while now I wanted to replace.
I am so excited about it.
I wanted to replace the word excited with the word happy.
So how do we do it.
We cannot hit AI right now because we don't want to get into the insert mode.
So we will use our arrow keys to go down to the word excited so I could do ah once I had ah I could
do h.
It only replaced one letter if I wanted to do again the second letter.
You move you closer to the right it are and then do a and so forth.
But I would prefer that you do escape out of it and then do x x x x x and then you hit AI and then p
y you escape again so you can move around.
You could go up, you could go down if you wanted to move around.
Now if what if you wanted to go to the end of this file and now you wanted to create a new line right
below it before I am so happy about it.
You had oh, this will create a new line for you.
And also it will automatically put you into the insert mode so you could type anything like blah, blah,
blah.
You just noticed that you just type J by mistake.
Now how do you remove J, you type X?
Now remember, if you're going to type X, it will write X instead of deleting it.
Look see it typing the X, so Y to delete that character.
How do I delete that character is because you cannot delete.
Why.
Because you are in insert mode.
How do I get out of insert mode.
You hit, you're saving life saving key is escape.
As soon as you hit escape you see the insert mode is gone.
Now when you hit X X it deletes those two characters that you added by mistake.
It was a typo that you added sameway.
If you wanted to go up, you could if you wanted to write something right here and if you type I, you
notice it, start writing right in the middle.
Hello.
Hi C without giving a space.
So let's do escape again.
Hit X, move the cursor to the left and X, OK, and now you have that space in the middle.
Now how do I write.
By putting a space in the middle.
I do a so a will automatically advance to the next space.
So hello.
Hi.
By Space World.
OK, now you're still in turmoil.
What if you were to save it?
Before you say it again, get out of insert mode by hitting escape and do shift.
Xie xie, this saved your bobcat my first fire and it is saving your first file.
Now, what if I wanted to delete the line, blah, blah, blah, the third line.
So I'll go back into my file by my first file.
Move your cursor down to blah blah blah and hit Deedes twice.
One, two.
There you go.
It removes a line that you added that wherever you wanted to go, if you want to, OK, you removed
it by mistake.
No problem.
It you will bring it back again.
You could save it through shifts or you could save it through column.
Right.
Quit and bang you could hit and and that's how you saved a file.
Now let's go back into the file one more time.
V.I. My first file and I want to let's say I have a file which is huge and I want it to search for a
specific word and I'll file let's say I wanted to search for a lesson.
I wanted to search for l so you could do a search for it.
Two ways.
I hope you remember the command.
Correct.
And then you search for lesson from where my first file and only bring that one line that has the word
lesson.
But if you are in V.I. mode, you can also do that same search and now you could just simply make sure
you are not in insert mode.
Simply hit slash.
And type Élysées, so and lessen it and turn and there it will bring you to exactly the word that you
wanted to change perhaps.
Are you looking for.
So these are the few commands that we have about creating a file using V.I..
We do have many different commands or keys that we could use in V.I..
I have included in this lecture.
I have included all those keys and as a as a handout.
So please look into those and try every single key.
I really want you to be very familiar with this and become eventually become an expert.
So when you typing in something in your text file, you know exactly which key you're going to work
into or exactly the key you going to use.
One common mistake that everybody is going to make is when you are in insert mode, you're probably
going to have to get out of it.
You can you typing this and that, but you cannot.
So your life saver as you do colon now first, sorry for his escape colon.
Q Now this time don't write w the W will write your changes the file.
You don't want to make changes.
So just to quit colon quit bang hit enter.
Verify it.
They go see now you don't have that garbage that you were going to write your file into.
So this is another way you get out and change your file.
So please practice man also give you different options to use it.
There's again there's another editor if you like to use, which is Vem, which an advanced version of
V.I. you can use that to, which is also available.
Most of the links, distribution, whichever you like.
But please to practice practice as much as you can.
And I would recommend that you create files, many files in your home directories or within your subdirectories,
create your files and write whatever you want to write A.B.C. or write a story or whatever and change
your text.
This is this is going to allow you to practice the editor.