लिनक्स संबंधी सभी डाउन लॉड्स के लिए निम्न लिंक क्लिक करें:
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:
# vi /home/anil/file1
If it is a new file, we will see something as under:
~
~
~
~
~
“/home/anil/file1” [New File]
There are three modes of working in vi editor. These are:
Command mode, Text mode, and Execute mode.
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
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 n.
Other commands used within command mode are:
Saving text :w
Quitting after saving :q
Saving and quitting :wq
Forcefully quitting without saving :q!
Text mode:
We use text mode to type in the text in the file. We have the following options to insert the text:
Command Action Details
i : insert What ever we type, will be inserted from the current position of cursor
a : append What ever we type, will be inserted from one position after the current
position of cursor
o : open What ever we type, will be inserted from one line below the current
position of cursor
O : open What ever we type, will be inserted from one above the current
position of cursor
cw : change word Replaces the word that comes after the current position of cursor
Execute mode:
We can run regular bash commands from here. For this just type :! followed by the command. For example:
:!ls /etc/cron.daily
This will list all files in /etc/cron.daily directory.
No comments:
Post a Comment