Dec 192017
 
VI is a screen text editor written for the IBM PC. Unix clone.
File VI.ZIP from The Programmer’s Corner in
Category Word Processors
VI is a screen text editor written for the IBM PC. Unix clone.
File Name File Size Zip Size Zip Type
VI.COM 24921 12825 deflated
VI.DOC 19021 5823 deflated

Download File VI.ZIP Here

Contents of the VI.DOC file


------------------------------------------------------------


===== VI =====


------------------------------------------------------------

-- Free VI version 1.9a. --

-- Copyright 1987, 1988 by Sue Doe Nim. --

-- This program may be freely distributed --

-- provided that this notice remains intact --

-- both in the program and in the documentation. --

------------------------------------------------------------



VI is a screen text editor written for the IBM PC. It has been

given the same name as the screen editor for the Berkeley Unix oper-

ating system. This is no coincidence: with a few exceptions, this

editor is a subset of the latter. Users familiar with Unix can skip

to the command summary at the end of this file.



This editor requires an 80-column display, MS-DOS 1.1 or higher,

and 128K of memory.



Getting started

------- -------


To edit an existing file, type


vi name


as a DOS command. The first few lines of the file will then appear on

the screen, and you may use any of the editing commands to modify it.

For example:












dw delete a word

de delete a word, leaving punctuation

dd delete a line

3dd delete three lines

itextEND insert text

/string search for string

xp transpose characters (actually two commands)


In addition, all of the keys on the numeric keypad perform as labeled.

When you are finished editing, type ZZ or ":x" to write the correc-

tions to disk and quit. If no corrections were made, then ZZ just

quits. To quit without saving corrections, use ":q!".


If the file named in the DOS command "vi name" does not exist, VI

starts with an empty file, into which text can be inserted. This is

how VI can be used to create a file.



VI States

-- ------


VI has three states, all of which occur in at least one of the

above commands. They are,


o Command mode. This is the normal and initial state. All

commands return here after completion.


o Insert mode. Characters typed in insert mode are, as the

name implies, copied into the file instead of interpreted as

commands. The "Escape", "End", and "Insert" keys return VI

to command mode (and vice versa for "Insert"). In this mode













the cursor is larger than in command mode, in order to help

you keep track of the program's mode.


o Last line mode. In this mode the editor is reading text for

a ":" command or a "/" or "?" search. The text ends with

or "Escape". Control `U' deletes the text but not the

":", "/", or "?" (unless there is no text).



Counts Before VI Commands

------ ------ -- --------


Many VI commands can be preceded by a number. The effect of this

number is usually to repeat the effect of the command. Sometimes,

however, it has other meanings. In many cases it is ignored.



The Screen

--- ------


The first 24 lines of the screen are used to display the file;

the last line is used for last line mode and for messages. Lines past

the end of the file appear as lines consisting of a single tilde

("~"). Tabs are expanded to columns 9, 17, 25, ..., 73, 1, .... Long

lines are wrapped around, so that they may take up several lines of

the screen. "@" lines indicate that the next line is too long to fit

on the remainder of the screen. The user should not create lines too

long to fit on a screen, although VI will not stop him from trying.


In case DOS (or a program bug) scrambles the screen, ^L will

restore it to what it should be.














If a command causes the cursor to move to a part of the file

which is not currently displayed on the screen, VI will automatically

scroll as necessary. VI also has commands to explicitly request

scrolling:



^F or PgDn Move the screen Forward one screenful, keeping

the last two lines of the old screen as the

first two lines of the new.

^B or PgUp Move Backwards one screenful.

^D Move Down 1/2 screen.

^U Move Up 1/2 screen.

^E Move Down one line.

^Y Move Up one line.



Motion Commands

------ --------


The arrows on the numeric keypad perform as labeled. Also, VI

has a rich assortment of other commands to move the cursor. These

are:



+ or Move the cursor to the first nonblank character

of the next line in the file. (All motions

referring to lines put the cursor on the first

nonblank character of that line.)

- Move to the previous line.

$ Move to the end of the current line.

0 Move to the beginning of the line.













fx Find the next occurrence of the given character.

The search is limited to the current line.

Fx Same as fx, backwards.

; Repeat the previous f or F.


/string Search for the next occurrence of the given

string. This search starts at the current

position, but may wrap around the beginning of

the file.

?string Same as "/", searching backwards.

n Repeat last "/" or "?" search.

N Same as "n", in the opposite direction.

H or Home Move the cursor to the first line of the screen.

M Move to the middle line of the screen.

L or End Move to the last line of the screen.

nG Move to the th line of the file.

G Move to the last line.

% Move to the matching parenthesis, bracket, or

brace.



The Delete Operator

--- ------ --------


If one of the above motions is preceded by the letter "d", then

VI will delete the text, from the old position to the new position.

This called an operator because it changes the effect of the ensuing

motion command. The repetition count for the motion command may

either precede or follow the "d"; the effect is the same.














Also, "d" may be doubled (i.e. dd or 7dd) to delete one or

several lines. If D is capitalized, it deletes through the end of the

line.


Other operators are "c" (change) and "y" (yank), described later.



Other Deletion Commands

----- -------- --------


x or Delete Functions the same as dSpace; deletes one

character.

X Deletes backwards one character; same as dh.



Insert Mode

------ ----


A number of commands place the user in insert mode. They are:



i Enter insert mode, inserting text before the current

character.

a Insert after the current character.

A Insert after end of line.

o Open a new line after the current line and enter insert

mode.

O Open before current line.

c, cc, C "c" is an operator, similar to "d". It

deletes text and leaves the editor in insert mode. For

example, "cw" changes the current word; "cc", the

current line.













To exit insert mode, use the Esc key, the Ins key, or the End

key. To delete all characters typed so far in the current line, type

Control U. Insert mode also supports Control-W to delete the most

recently typed word, and Control-V to strip the next character of any

special meaning. In this version of vi, the backspace key will also

allow you to delete a mistakenly typed carriage return.




Other Modification Commands

----- ------------ --------



rx Replaces the current character with the character x.

J Joins two lines; i.e. concatenates them, adding a space

between them.



Undo and Repeat

---- --- ------


In case of a mistake, the "u" command will undo the effect of the

last command which modified the file. Only the most recent change can

be undone in this way.


The dot command (".") will repeat the last command which changed

the file.























Moving Text

------ ----


To move part of a file, one uses the operations of yanking and

putting. Yanking consists of copying part of a file into a special

buffer; putting copies that buffer into another part of the file.


To yank text, use the "y" operator (y, yy, or Y) in the

same manner as the delete or change operators. Then move the cursor

and use the put command (p) or put-before command (P) to put the text

elsewhere. For example,


5G yy 9G p


places another copy of the fifth line of the file after the ninth

line.


The delete and change operators also save the deleted text in a

yank buffer. Thus the command "xp" (actually two commands) exchanges

two characters by deleting the first and reinserting it after the

second.


In addition to the default yank buffer, VI has 26 other yank

buffers, tagged by (lower-case) letters of the alphabet. To let a

yank, put, delete, or change command command refer to one of these

buffers, precede the command with the quote character and the letter

of the buffer.


Transferring text between files can be done in one of several

ways. First, the command


:r name












reads the named file into the current file, following the current

line.


The reverse of this operation is the command,


:p name


which puts the buffer into a file of the given name, destroying the

file's previous contents, if any. "x:p and :"xp are also valid; both

do the same as :p with buffer x.


The last way of transferring text between files is to yank one or

more pieces of text, switch the main file via


:e name

or :e! name


and then put the text into the new main file.



Marking Positions in the File

------- --------- -- --- ----


You can mark your current position in the file by typing `mx',

where `x' may be any lower case letter. You can then return to that

spot by typing 'x to return to that line or `x to return to the exact

character. Of course, you can also use 'x or `x in an operator, e. g.

m'x or y`x. Also, '' or `` will return to the starting point of the

last `/', `?', `n', `N', `G', `H', `M', `L', `%', ``', or `'' motion.



















Helpful Hints

------- -----


In addition to ending insert and last line modes, the Escape key

can be used to delete a partially complete command. It also momentar-

ily enlarges the cursor. This makes it easier to see--it is easy to

lose the cursor after a locate operation.


To insert an escape code into the file, use control-[ or Alt-27,

or precede it with ^V in insert mode.


One feature that VI currently lacks is the ability to change all

occurrences of a given string to another string. This can be done

with alternate uses of the "n" and "." commands (and a little

patience).


The current implementation of this program lacks the capability

of editing files larger than will fit in memory under the small memory

model. That translates into about 50K. If you reach that limit, the

program will display a message and suggest that you save your correc-

tions immediately. It is strongly suggested that you do so, as the

editor will be in an unstable state; continuing to use it after such a

message would likely result in loss of data. This is indeed unfor-

tunate, but at least it is better than earlier versions, which termi-

nated immediately and lost all corrections. If you need to edit

larger files, find the `split' utility (on a bulletin board near you)

or buy the MKS vi editor.



------------------------------------------------------------














The above is a tutorial introduction to some of the most common

VI commands. A list of all VI commands appears in the command sum-

mary, below.






























































Command Summary

------- -------



Colon commands:


:w [name] write to file

:q quit

:q! abort

:wq [name] write and quit

:e name edit new file

😡 or ZZ same as :q or :wq, depending on whether

corrections have been made

:e! name discard corrections and edit new file

:f or ^G print file name, status, and length

:ve print VI version

:r name read file into current file

:["x]p name put to file



Character motions:


h or Backspace back character(s)

Space or l or Rightarrow forward characters

j or ^N or Downarrow down lines, same column

k or ^P or Uparrow up lines, same column

$ down lines, end of line

0 beginning of line

^ first non-white character in line

w next words

b back words












e end of th word from here

W, B, E same as w, b, e, with blank-delimited words

| move to column

% match (), [], or {}.

`x character of mx command (x=any lower case letter)

`` start of last /?nNGHML%' or ` motion


/string search

?string backwards search

/ or ? forward or backwards search, same pattern

n repeat last search

N repeat last search, opposite direction


fx find next th occurrence of x

Fx find previous th x

tx next th x (not inclusive)

Tx previous th x (not inclusive)

; repeat last f, F, t, or T

, reverse of ,



Line motions:


+ or th next line (first nonwhite)

- th previous line

_ current line or st next line

H or Home top of screen (or th line on screen)

M middle of screen

L or End last line of screen (or th line from bottom)

nG go to th line (end default)













'x line of mx command (x=any lower case letter)

'' start of last /?nNGHML%' or ` motion



Operators:


d, dd, D delete

c, cc, C change

y, yy, Y yank

(Note that in this implementation 'Y' is equivalent to

'y$' instead of 'yy').



Insert Mode:


i or Insert insert before current character

a insert after current character

I insert before first nonblank character in line

A append to end of line

o open after current line

O open before current line



Other modification commands:


x or Delete delete character; same as "d "

X delete previous character; same as "dh"

s delete character and enter insert mode;

same as "c "

S delete line and enter insert mode; same as "cc"

r replace character

J join two lines













p put yanked text

P put yanked text before current line or character

u undo previous command

. repeat previous command



Screen commands:


^L redraw screen

^F or PgDn forward screens


^B or PgUp back screens

^U, ^D up (or down) 1/2 screen

^Y, ^E up (or down) lines

z or zh redraw with current line (or th line) on top

z. or zm redraw with current line (or th line) in middle

z- or zl redraw with current line (or th line) at bottom

z+ redraw with current bottom line (or th line) at top



Miscellaneous:


mx mark here as mark `x' (Cf. 'x and `x above.)

(x = any lower case letter)


 December 19, 2017  Add comments

Leave a Reply