- In this video, we are going to talk about text editors.
So working in Linux mostly happens from the command line.
And that means that you also
need a command line text editor.
Of course the graphical user interface is text editors
but these are useless if you're not
in a graphical interface.
Nano is very easy to use,
and it's available on many Linux installations by default.
Vim is vi improved,
and vi improved is a very powerful editor
with advanced programming features.
Now, the thing is that on some systems
you will only find vi or vim.
And for that reason, you should invest
your time learning vim if you wanna go deeper with Linux.
If you're not interested in going deep
and knowing all about the Linux operating system
feel free to use the nano editor.
But if you really want to master Linux
and have access to a powerful text editor,
vi or vim is unavoidable.
The downside is that vim is more difficult to use,
but as I told you, you should learn how to use it anyway
for the simple reason that it is always available,
even on very old UNIX systems.
Vim is invented in 1984.
So even if you get to a real old UNIX system,
you type, vi, it will work.
And in case you are confused, what is it, vim or vi?
Well on most Linux distributions, it's exactly the same.
We don't care about the small differences
between the two of them in this course.
I just want you to learn how to work with them
because you will appreciate, as it is a powerful
and programmable editor that allows you
to perform text file operations in an easy way.
Now, you might notice that
your distribution is not running the editor
that you want to use.
And if you want to change that,
you can use this command, export EDITOR=$(which vim).
I will show you that command in just a little bit,
but first I wanna have a quick look at nano.
So here we go.
I'm typing, nano, my file.
And this is the nano interface.
Now nano has been created to be intuitive.
So you can start typing,
and you don't need to do anything complex.
So no complex stuff.
The only thing that is complex is what you do when
you are done with nano.
Well, everything that can be done
when you are done is in the lower part of the screen.
You can see on the left, there is key strokes
that start with a caret.
The caret is the control key.
So if you use control-X, for instance, then you will exit.
- And there are more options that start with the caret.
The other options are to the right
on the bottom of your screen.
They start with M.
Now what is M?
M is what we call the meta key.
And the meta key or most keyboards is the alt key.
So control and alt is what you need.
So I'm going to use control-X,
and control-X is asking me, save modified buffer?
Yes, I want to save modified buffer.
And file name to write?
Oh, I noticed that I made an error when I created my file,
so I can still change it here.
Also nice, is that it is asking me for the format.
Am I writing in DOS format or in Mac format?
Well, I don't care about format.
This is Linux, right?
So we don't care about DOS and Mac.
So I'm just going to press Enter
and save file on the different name.
Why is it asking that?
Because I just changed the name.
So yes, I want to save file under a different name,
and oh no, error writing my file, permission denied.
Why am I getting permission denied?
Well, it's only one way to figure out,
I'm going to not save the modified buffer.
And where am I?
I am in tmp files, and apparently
I don't have permissions to write there.
No permissions to write there?
Well, that is something that we need to talk about later.
I don't wanna talk about permissions now.
So let me go to my home directory and try again.
Nano new file,
hello world,
control-X, same sequence again.
Yes, I want to modify, I'm just pressing enter
to write a new file and here we go,
new file has been created, as you can see.
That is nano, and nano, as I said, is easy.
The vi is not, but you should learn how to work
with vi anyway, and that's in the next video.