Introduction
An editor is a program used to edit files. Files can be of different types such as : Text Files, Graphic Files etc. Depending upon what they contain.
An editor is a program used to edit files that contain text only. For e.g. : A letter of source code of a program.
Linux offers editors such as 'PICO', 'VI' and many others.
The 'VI' Editor
The vi (visual) editor is a full screen editor. This means that you will be able to position the cursor to the location in the file where you want to place the changes and addition.
The changes that you make will reflect on the screen. Vi will work with many different types of terminals if u set the terminal type correctly before invoking the editor.
Vi editor is one of the most powerful and earliest editor available in Linux and Unix environment.
VI Basic Concepts
The three models of operation in vi are :
1. Command Mode
2. Insert or Input Mode
3. Last Line Mode
At any time vi will be in one of these mode.
The Command mode is one in which user is able to enter the commands, for e.g. To add text, to delete text.
In Input or Insert mode the user can enter data or edit the data.
The Last Line mode is one in which the user is able to enter special commands, which typically start with, :
When VI is invoked, it comes up in command mode. For the user to be able to enter any text, the user must type a command that takes him into 'input' mode. The user can come back to 'command' mode by pressing the 'Escape' key.
Starting 'VI'
The 'vi' editor can invoked by typing the following command at the prompt.
At command prompt, type the following,
[user1 @linux-mac user1]$ vi
Since the file name is not specified with 'vi' command ''Empty Buffer" is displayed at the end of the screen.
An existing file can also be opened by specifying it's name with 'vi' command.
The cursor is brought to a specifying the line number at the command promp along with the file name.
At the command promp type the following :
[user1 @linux-mac user1]$ vi +5 candy
The above command positions the cursor to the 5th line of the file called 'candy'
Now type the following command :
[user1 @linux-mac user1]$vi +/fruit candy
This command will take the user to the line in the file called 'candy' which contain the first occurrence of the string 'fruit'.
Inserting Text
To enter the data user have to switch to input mode by pressing character 'i'.
List of Insertion Commands
Command Purpose
i : Invokes insert mode and inserts before character.
I : Same as 'i' but insertion is at the beginning of the line.
O : Open blank line before the current line.
O : Same as 'o' but puts blank line after current line.
a : Same as 'i' but appends after cursor.
A : Same as 'a' but appends at the end of the line.
J : Join the next line with the current line.
Navigation
The 'vi' editor gives the option of navigation without relying on the cursor keys.
There are other commands to help in scrolling the screen. The character 'n' before the commands which are used in cursor control.
List of cursor navigation commands
Command Purpose
k : same as "up" arrow key
h : same as "left" arrow key
l : same as "right" arrow key
J : same as "down" arrow key
w : moves forward by word
'n' w : moves forward by 'n' numbers of word
e : move to the last character of the world or that of next
'n' e : move to the last character of n(th) next word.
b : take the user back by word
'n' b : take the user back by 'n' number of words
0 or '^' : take the user to the beginning of the line
$ : take the user to the end of the line
'n' G : take the user to the n(th) line
L : take the user to the last line
Commands For Scrolling
List of screen scrolling commands
Command Purpose
Ctrl - f : Scrolls a screen forward
Ctrl - b : Scrolls a screen backward
Ctrl - u : Scrolls half a screen backward
Ctrl - d : Scrolls half a screen forward
Ctrl - L : Refreshes the screen
Undoing The Changes
'vi' has the option for undoing the last action. The 'u' command removes the effect of last command. For e.g. If the block of text has been deleted by mistake, it can be undone by using the 'u' command.
Copying and Moving Blocks of Text :
To be able to select a block of text, we need to select the lines of text by taking the cursor to the first line of text block that we have to copy. We then need to first of all specify the no of lines followed by the command 'yy'. This copies the specified lines to temporary buffers. To be able to copy a block of text, we move a copy of the specified text to the temporary buffer. To be able to move a block of text, we move the specified text itself to temporary buffer. The paste command 'p' moves the text store in the temporary storage to the current cursor location.
List of Copy Commands and Move Commands
Command Purpose
Yy : copy a line into temporary storage
'n'yy : copy 'n' number of lines into temporary storage
Dd : move a line in to temp storage
'n'dd : move 'n' lines in to temp storage
p : move the text from temp storage to the current position of the cursor.
https://youtube.com/channel/UCLZqVRZUkuXIlST8BteqTig
This is the link of my YouTube please visit at this link and if you like it don't forget to like, share and subscribe the channel.
Thanks for the information best places for water sports in usa
ReplyDelete