Search This Blog

Thursday, January 19, 2012

VI editor.

This is the most basic and widely used linux utility for editing the text files in linux.(You may consider it as notepad in windows).

However it has a little complex way of editing but once you are familiarize with the command its no difficult .

Before start using VI editor ,you must learn the 3 modes of vi editor.
1)Command mode.
2)Insert mode.
3)Last line mode.

Lets explore them one by one.

Create a file .

# touch File1.txt

Now Open it using vi .

#vi File1.txt

Now try typing letters such as 'b','c','d'
What did you notice?
You were not able to type any of above characters this is not limited to just above 3 characters infact most of the characters are not getting typed when you open the editor.
Why?
You are not yet in Insert mode.

How to go into Insert mode then?
ok lets start from beginning .
press Escape character on keyboard.
type
:q

you are back to terminal again.
Open the file again
#vi File1.txt

Press 'i' ,You are now in insert mode and can type anything you wish.

just type below characters in the file.

This is my first usage of vi editor.
I know its complex but i will learn it soon.

press Escape character in keyboard
Now type
:wq

What did you do ?
You just saved and closed to file to return back to terminal.
What ever you enter after typing ':' are considered as Last line commands .
They are useful for saving file,quite the file and other tasks.
e.g.
w:saving the file
q:quit the file





Questions and Answers :

How to go to End or Beginning of file in VI editor..?
Ans : Beginning and end of file, i.e. :0 and :$  

How to visit specific line of the file?

Grep command comparison with vi string find....

String replacement.
#
How to search a specific string in VI editor?

How to delete a line ? 

Set command 

No comments:

Post a Comment