Get Started With The Basics Of Oracle Linux Series Part 1 – How to Learn the Basics of Using VI

black yellow modern multipurpose youtube thumbnail

Today I am going to be showing you all How Getting Started with Linux tips with hopeful tips called VI and VIM in Linux.

vi basics

Open file with vi

vi /etc/cc

Of course, just opening the file gets you nowhere, unless you only want to read it.

So in order to add some text we will need to put in the command

ESC + i

I is for insert

There you have it now you can edit, or type in whatever you need to.

Now when you think you are done editing or typing in whatever you need you will have to save the file.

And How we do that is we would click on

ESC + w

(w for write)

To close the file we would just click on 

ESC + q (q is for quit)

Of course, there is a lot more that you may need to do. Let’s have a look.

Removing Lines 

So you may find yourself that you need to delete the entire line instead of just one work.

Just place the cursor at the beginning of the line and type:

ESC + dd 

Sometimes you delete something that you, don’t actually want to delete or delete it by accident, don’t worry you can just click on

ESC + u (u for undo)

Now if we completely change our mind and want to quit without saving any of the text that we input

ESC + q!

(q! for quit and I *really* mean it!)

This will override default setting, if you make change to a file, and will quit without saving anything.

Ever lose a word and just can’t seem to find it, don’t you worry, this feature is actually equivalent to find in windows type in :

ESC + /word

If you’re looking for the word bingo in your text (as in: ‘vi is so easy I have ‘a dog named bingo) you would type:

ESC /bingo

Can I change that word?

Maybe you don’t want to use the word bingo. . You can use vi to change the word as well

First you could use the

/bingo

to look for that word. When you find it, you would then type

ESC : s/bingo/toby/

to replace the word on that line.

If you were sure that you wanted to replace all instances of that word in the whole text, you could type this

ESC :%s/bingo/toby/g

and bingo would be changed to toby throughout the entire text.

If you want to get some control over what you replace – that is you want to used both bingo and toby, then you would add gc to the end:

ESC :%s/patrick/toby/gc

Vi will now ask you for confirmation.

Vi configuration settings

There are some basic vi configuration setting that you should be aware of if you want to use this text editor comfortably.

Word Wrapping

If you don’t want your words running off the page into outer space, you can set the word wrapping feature in vi

ESC : set wm=25

You are done.

Here is a video on how to do it step-by-step if needed.

Hope you enjoyed this tutorial.

How2TechTips.

Keep Techin’ ON.

%d bloggers like this: