So let's demonstrate some more VIM skills. I'm using vim demo
demo file and then I'm going to type some text.
All right, here we have a little Linux history file and let me show you some VIM operations
on that. First I'm going to the top line because I can see Linuxes with lowercase and oh
boy, I'm not sure if there's any other occurrences of Linux to lowercase in this file.
So let me use colon percent s for substitute and I'm going to substitute
Linux lowercase with Linux uppercase and doing that G. G is for global.
There we can see that all occurrences, well, that happens to be one only have now been changed.
Now I'm going to use W. Do you see how convenient that is?
W to go to the next word and B to go back to the previous word.
You can also jump in one way to the end of the command line.
You can also jump using one command to the end of line. That will be $ or or to the beginning using caret.
Now how about delete the current word? Well, that would be dw. Oops, now it is deleted.
In fact, I didn't want to delete that.
Let me use U for undo, one of my favorites. Every now and
then you need to open a line above the current cursor position.
Let me open a line and call it facts
about Linux using Escape again and using senumber.
Not because that is so useful here in this example, but mainly because in programming it is very
useful if you can refer to line numbers. You don't want them to be around all the time.
But just for once that would do.
Now I'm going to use Escape. And did you see that I'm using Escape
all the time? In fact, because pressing Escape makes sure that I'm in command
mode and I'm using shift zz, which is shortcut for write and quit.
I did not want to write and quit.
In fact I wanted to open more text.
I am going to add one more line.
Linux comes forward of the Unix operating system.
Now I'm going to do something that people who are new to Linux do frequently. What do
you do in Windows when you are done editing your file? You close the window, right?
And that's asking. Close the window? Yeah, let's close the window. And now my window is gone.
I don't have my terminal anymore.
So I need to get back to my terminal.
And in my terminal I'm going to use vim demo file again.
And now we get what I wanted you to be aware of.
So what is it telling us?
It's telling us that the Swap file was found.
demophile SWP what is this swap file?
This swap file is a file that is opened by the VIM editor when you are editing the file.
And if the file was closed in an unexpected way then
the swap fail will be found allowing you to recover it.
And that is why we get this explanation and all the different options. Well, the option that I want is
R for recover but also keep in mind the other options if you're sure you don't need it, you can
as well delete it or open read only to check what is going on. But I want to recover.
Then I can see that the recovery is completed and I'm pressing enter and there we can see
that even the last line that I have added was committed to the SOP file. So yeah, my
beautiful facts about Linux history file is now complete. I would say before you quit this video, press
the pause button and make sure that you read the file because nothing in this is a lie.