Você está na página 1de 9

Editor

Programming Tools
June 2011

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 11
Objectives
Able to edit a text file using vi editor(like insert,delete, copy,paste,search/replace) with
proficiency

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 22
The vi Editor
vi stands for visual editor.
Visual Interface to the ex line editor
Holds file being edited as an internal buffer
Screen acts as a window onto the buffer
Operates in two basic modes
Command mode
Insert mode

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 33
Starting vi
vi
Starts vi with an empty buffer
vi file
Starts vi opens file for editing
vi +n file
Starts vi opens file at line n
vi +/pattern file
Starts vi opens file at the first line matching pattern
vi always starts in command mode

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 44
vi mode
Command Mode
In command mode every character typed is a command
You can move about in the buffer
Characters/lines can be deleted or moved
To enter text shift to insert mode

Insert Mode
In insert mode characters typed are entered into the buffer
Shift from command to insert move using:
i insert text before cursor
a append text after cursor
Shift from insert back to command mode by typing ESCape

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 55
vi basic commands
Common vi Commands:
i Insert at the current position
a Append at the current position
o Insert as a new line
x delete the current character
dd delete the current line

nG Go to line n
/textCR Find text (forward search)
?textCR Find text (backward search)
n Find next occurrence of text (same direction)
N Find next occurrence of text (opposite direction)
Search & Replace ( ex mode)
:1,$s/delhi/mumbai/g ( Replaces every occurrence of the string delhi with mumbai)

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 66
Vi commands
Typing the : character in command mode causes a prompt to appear at the bottom of the
screen
ex commands can be typed here
:q (quit vi and will complain if there are unsaved changes)
:q! or ZZ (quit and lose any unsaved changes)
:r filename (read the named file into the buffer)
:w filename (write the buffer to named file)
:w (rewrite the buffer to an already named file)
:wq save & exit

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 77
Disclaimer

Aricent Group makes no representations or warranties with respect to contents of


these slides and the same are being provided as is. The content/materials in the
slides are of a general nature and are not intended to address the specific
circumstances of any particular individual or entity. The material may provide links
to internet sites (for the convenience of users) over which Aricent Group has no
control and for which Aricent Group assumes no responsibility for the availability or
content of these external sites. While the attempt has been to acknowledge
sources of materials wherever traceable to an individual or an institution; any
materials not specifically acknowledged is purely unintentional

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 88
Thank You

The contents here are for Aricent Group internal training purposes only and do not carry any commercial value Restrcicted Aricent Group 2011 10
10

Você também pode gostar