#vi - It is a text editor in Linux. We use vi, either to create a new file or to modify an old file. It should be used with a file name following it, which is as follows:
if it is a new file, we will see something as under.
~
~
~
~
~~
~
~
~
“/home/ajay/file1” [New File]
Command mode –
It is the default mode. It is used to search text, delete characters, words or lines or scroll within the text. We can come back to the command mode from text mode by using escape (Esc) key. We can use this mode to enable line numbering also, which is as follows:
: set nu
Deleting text – To delete the text in vi, we have three commands associated with the current location of cursor.
dd - To delete the whole line
dw - to delete current word
x - to delete current character
yy - to copy the whole lines
pp - to paste the whole copied line
Searching text –
Searching of text can be done easily with forward slash. For example if we want to search the word India, we can type the following:
/India
it will highlight the first place of the found word. To go to the next instance just press an other commands used within command mode are:
it will highlight the first place of the found word. To go to the next instance just press an other commands used within command mode are:
Saving text: w
Quitting after Saving: q
Saving and Quitting: wq
Forcefully quitting without Saving: q!
Forcefully quitting with saving: wq!
Quitting after Saving: q
Saving and Quitting: wq
Forcefully quitting without Saving: q!
Forcefully quitting with saving: wq!
K - up the file line
J - down the file contents
W - for starting the word
E- for editing the word
Back - delete only insert mode
OD - delete the full line
U - undo the file (without insert)
YY - copy the all line (selected line)
PP - paste the all line
: set NU - number of lining (without insert)
Small p - up the paste the line
Copy p - down to paste line
No comments:
Post a Comment