Maruthi Class Vi
-
Upload
maruthi631 -
Category
Documents
-
view
219 -
download
0
Transcript of Maruthi Class Vi
-
8/10/2019 Maruthi Class Vi
1/4
Editing- it includes both creating a new fle and modiying an existing text fleEditor- its a utility that acilitates the editing task.Editors are classifed into 2 types: line editors and screen editors
Line Editors: changes are applied to a line or group o lines. o edit a line wemust select a line or group o lines Examples: sed! ex
"creen editors: it presents a whole screen o text at a time examples: #i
The vi Editor:
$hen we in#oke #i editor it copies the contents o the fle to a memory spaceknown as bu%er once the data ha#e been loaded into the bu%er the editor presentsa screen ull o the bu%er to the user or editing.
& the fle does not exist an empty bu%er is created.
Format:Vi options flelist
$hen we exit #i! the bu%er is erased! at exit time we ha#e two options $e can 'uit #i without sa#ing the fle
$e can sa#e the fle.
Modes:
here are two modes
(ommand mode
ext mode
Command mode:
$hen the #i editor is in command mode any key that is pressed by the user isconsidered a command. )s the command is entered its executedText mode:
$hen the editor is in the text mode any key that is pressed by the user isconsidered text.
*eault mode is command mode ie.! when we in#oke #i you are always in thecommand mode. o exit #i we must be in command mode.
CommandsAdd Commands:
(ommand
+unction
i &nserts text beore the current character& &nserts text at the beginning o the current linea )ppends text ater the current character) )ppends text at the end o the current lineo ,pens an empty text line or new text ater the current line, ,pens an empty text line or new text beore the current line
-
8/10/2019 Maruthi Class Vi
2/4
Insert commands (i and I)
Lower case insert command i changes to the text mode! we can then entertext
$hen we through entering text we return to the command mode by keying
esc./ppercase insert command & opens the beginning o the current line or
inserting text.
Append Commands (a and A)
$e can append the text ater the current character a or ater the currentline ).
e! "ine Commands ( o and #)
Lower case new line o command opens a new line ater the current line
/pper case new line , command opens a new line abo#e the current line
C$rsor Move Commands:
(ommand +unction%ori&ontalMovesh!!backspace
0o#es the cursor one character to the let
1!!spacebar 0o#es the cursor one character to the right
0o#es the (ursor to the beginning o the current line3 0o#es the cursor to the end o the current line
VerticalMovesk
0o#es the cursor one line up
4 0o#es the cursor one line down- 0o#es the cursor to the beginning o the pre#ious line5! 6eturn 0o#es the cursor to the beginning o the next line.
%ori&ontal Move Commands:
7ori8ontal mo#e commands mo#e the cursor one character to the let or rightor to the beginning or end o the current line.
Vertical Move Commands:9ertical mo#e commands mo#e the cursor up or down one line.
'eletion Commands:
(ommand +unctionx *eletes the (urrent (haracterdd *eletes the (urrent Line
-
8/10/2019 Maruthi Class Vi
3/4
'elete Character(x)(urrent character pointed by the cursor will be deleted
'elete "ine (dd)&t *elete the current line.
oin Command()wo lines can be combined using the oin command
*crolling Commands:
/nix window is 2; lines long! when we are dealing with document longer than 2;lines we need to scroll through the bu%er to see the text."croll down means mo#ing down in the text toward the end o the fle"croll up means mo#ing the text up.
(ommand +unction(trl 5 y "crolls up one line(trl 5 e "crolls down one line(trl 5 u "crolls up hal a screen 12 lines(trl 5 d "crolls down hal a screen 12 lines(trl 5 b "crolls up whole screen2; lines(trl 5 "crolls down whole screen 2; lines
+ndo Commands
(ommand +unctionu /ndoes only the last edit/ /ndoes all changes on the current line
*aving and Exit commands
*ave !or, and contin$e (:!) "a#e and continue command sa#es the contents o the bu%er back into the
fle*ave to ne! fle (:! fle name)
$rites the contents o the bu%er to a new fle*ave and $it (..)
&t sa#es your work and exit rom #i./rite and $it (:!)
&ts similar to sa#e and 'uit0$it (:)
&t exits #i but only i the bu%er is unchanged0$it and don1t save (:2)
&t will 'uit the #i and dont sa#e the changes made
(ommand +unction
-
8/10/2019 Maruthi Class Vi
4/4
:w "a#es the contents o the bu%er without 'uitting #i:w flename $rites contents o bu%er to new fle and continues