Okay, let me give you an overview of different commands in Vim.
This is because there is Vim Cheat Sheets, and you know that Cheat Sheets are two-column
double-side printed in small print sheets of paper with just too many commands.
What I've tried to do, I've tried to give you a list of all the commands that really
matter.
Starting with escape, which is just the escape key.
Press the escape key to get from input mode to command mode.
Or the opposite, use I or A to enter the input mode, where I is insert and A is append.
Or O to open a new line in input mode.
Column WQ will write and quit.
And put an exclamation mark behind it if it's complaining or sending messages that you don't
know how to deal with them.
You can also use column Q exclamation mark to quit without saving anything.
As editing text files in Linux is often line-oriented, you're also going to like DD, which deletes
the current line.
Or YY, which copies or yanks the current line.
Then there is P to paste the text currently in the buffer.
Or V, which enters visual mode.
I like visual mode because you can use your arrow keys on the keyboard to select a block
of text and perform a manipulation on that.
You're probably also going to appreciate U for undo.
If at any time you've done something you regret, with U for undo, you can undo it easily.
And Control R is doing the opposite.
If you have undone one command too many, well, redo the last operation undone using Control
R.
There's a couple more, like GG, which will go to the top of the document.
That is convenient if you have a very large document, so that you can easily go to the
top or to the bottom.
Uppercase D will do the opposite and will go to the end of the document.
Slash text will search for text, and question mark text will search backwards for text.
Carat will move the cursor to the start of the line, and dollar will move the cursor
to the end of the line.
And then there is W, which will move to the next word.
And last but not least, the substitution operator.
So it's a colon percent S for substitute, slash alt.
So you're looking for the text alt slash new, which will substitute for the text new.
And the G at the end of the command makes it a global substitute, which means that it's
not doing it once.
It will do it any time it will find the text on the line that was provided.
Let me show you a bit of this.
So I'm using Vim, long doc, because I'm making it a long document this time.
And I'm just going to type a couple of lines with some random text that is mainly meant
to demonstrate what is going on.
And how are you again today?
And I think this is enough.
The file doesn't make too much sense, but that's not what matters.
It's enough to demonstrate what I want to demonstrate.
Let me get back to command mode to show you these commands.
So escape to get back to command mode, and caret to move to the start of the command
line, W to the next word, and dollar to move to the end of the command line.
And then G is doing nothing, but double G will bring you to the top of the document.
And uppercase G will bring you to the bottom of the document.
So let me go to the top and search for the text, how.
And oh, I missed my H, but you can see the result.
It is automatically selecting the OW.
It's even marking it in yellow, like it or not.
Now what else can we do?
We can do V for visual, and then using my arrow keys, I can select text.
So dollar to go to the end of the line, and D for delete.
And oops, in case you didn't like the delete, use U for undo.
Now how about colon, percent, S, slash, text, slash, whatever, slash, without the G behind
it will only replace the first occurrence of the matching text on a line.
That is why you have this colon, percent, S for substitute, slash, text, slash, whoever,
slash, G to make it a global substitute.
And there you can see this is how it is working.
I think we have seen enough about it.
There's only one thing remaining, and that is in case you want to know more about this
awesome editor, take 20 minutes to run through Vim Tutor.
Vim Tutor is an instruction document.
Use your arrow keys.
Follow the instructions that are displayed.
And by the time you are done, you are going to be a Vim expert.
Well, almost you are.
Let's get out of here.
I think we've talked enough about editors.
And as I told you before, you are not going to fail RHCSA if you can't master Vim.
Just use Nano instead.
Nano is okay as well.