Professional Documents
Culture Documents
VI Editor
VI Editor
VI Editor
Editor Concepts
Editing creating a new file and modifying an existing text file. An editor a utility that makes the editing task possible. A text editor differs from a word processor in that it does not perform text formatting, such as bold, center, underline, etc. A line editor a utility that applies changes to a line or group of lines; two common line editors: ex and sed. A screen editor shows a whole screen of text at a time; we can move cursor or select part of text, search for text, etc.
2
The Vi Editor
A screen editor available on most UNIX systems. When invoked, it copies the contents of a file to a memory space know as a work buffer. All editing are applied to the contents in the work buffer. If the file does not exist, an empty buffer is created. When we exit vi, the work buffer is erased. At exit time, we can do two things:
1. Quit without saving the original contents remain unchanged. 2. Save the file the original contents are replaced by the new version in the work buffer.
3
Vi Buffers
Work Buffer
This is where vi performs all editing Vi makes a copy of your file in the work buffer Makes all changes to the copied version Replaces original copy with edited copy when you save (:w)
Name Buffers
26 named buffers, each named by a letter of the alphabet Used to store a different block of text to recall later
4
Command Mode
Esc
Input Mode
Return
Insert (i, I) Append (a, A), Open (o, O) Change (c), Replace (r, R)
Last-Line Mode
5
Vi Mode
In vi, to find out what mode you are in, you need to create a vi start-up file (.exrc) In your home directory or in your cwd directory, create .exrc file with contents:
set showmode
File Names
When naming a file, avoid the following characters:
& $ Space * <> Tab \ () ; | # ^ [] ? ! {} / ~
10
11
Vi tutorial
To run vi tutorial session, execute the following command at the command prompt:
/usr/local/bin/vimtutor
12