📄 vi.doc
字号:
calvin(1) MS-DOG programmer's manual calvin(1)
------------------------------------------------------------
-- Calvin version 2.2. --
-- Copyright 1988, 1989, 1990, 1992, 1993 by Paul Vojta. --
-- This program may be freely distributed provided: --
-- --
-- 1. All files (vi.exe, vi.doc, and read.me) are --
-- distributed together in unmodified form (use of --
-- universally available file compression software --
-- is allowed, however); and --
-- --
-- 2. No fee is charged other than a nominal processing --
-- charge or a connect time charge. --
------------------------------------------------------------
(Earlier versions of Calvin have been released under the name
"Free VI.")
SYNOPSIS
vi file ...
vi +[number] file ...
vi +/pattern file ...
Wild cards may be used on the command line.
Calvin also supports the EXINIT environment variable, which may contain
:set commands (put spaces in place of equals signs).
DESCRIPTION
Calvin is a screen text editor written for the IBM PC. It implements
a subset of the Unix screen editor vi(1). Users familiar with Unix can
skip to the command summary at the end of this file. (Unix is a
trademark of Bell Laboratories.)
This editor requires MS-DOS 2 or higher and 128K of memory. It will
use all available memory for storing the file, etc.; optionally, it can
store additional information on disk.
It supports EGA 43-line and VGA 50-line modes.
INSTALLATION
Installation is fairly straightforward; you should copy vi.exe into
some directory mentioned on your PATH command.
There is one catch, however. If you want Calvin to use the disk to
store information which does not fit into memory (i.e., long files),
then you should tell it which drive and directory to use. This can be
done at any time using the :set directory command (see below).
However, if you edit long files often, it would perhaps be most
convenient to always set it when Calvin starts up. This can be done by
the DOS command line
set EXINIT=set directory c:/tmp
if, for example, you wanted to use c:/tmp as the temporary directory.
This line can also be placed in the autoexec.bat file.
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
itext<End> insert text (note that <End> refers to the "End"
key on the numeric keypad)
/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 corrections
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, Calvin
starts with an empty file, into which text can be inserted. This is
how Calvin can be used to create a file.
EDITOR MODES
Calvin has three modes, 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 Calvin 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 <cr> or
"Escape". Control-U deletes the text but not the ":", "/", or "?"
(unless there is no text).
COUNTS BEFORE EDITOR COMMANDS
Many Calvin 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
Most of the screen is 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, ... (although this can be changed). 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 Calvin will not stop him or her from
trying.
In case DOS (or a program bug) scrambles the screen, ^L (Control-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, Calvin will automatically scroll
as necessary. Calvin 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, Calvin has
a rich assortment of other commands to move the cursor. These are:
+ or <cr> 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<cr> 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<cr> 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 <n>th line of the file.
G Move to the last line.
% Move to the matching parenthesis, bracket, or brace.
SEARCHING
The backslash character `\' has a special meaning in strings used for
searching. Generally, it either adds or removes special meaning to or
from the following character. Currently, this means that \0 is
translated into the null character (Calvin treats null characters just
like any others), and that any other character is taken literally when
preceded by a backslash. Otherwise, a '/' indicates the end of a '/'
search string, and likewise indicates the end of a reverse search
pattern. So if you want to search forward for the string \/, use /\\\/
(the first slash means search forwards, the next two backslashes
translate into one backslash, the \/ then is translated into a single
forward slash). As for other `magic' characters available under
Unix<tm> vi, Calvin has not implemented them yet.
These comments apply equally well to search strings present in ':'
commands or '+' parameters.
THE DELETE OPERATOR
If one of the above motions is preceded by the letter "d", then Calvin
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), "y" (yank), and "!" (shell filter);
they are described later.
OTHER DELETION COMMANDS
x or Delete Functions the same as d<Space>; 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<motion>, 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<motion>, 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, Calvin 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.
You can also indicate that the file is to be read at a given line by
typing <n>:r name, where <n> is the line number (0 to insert at the
beginning of the file).
The reverse of this operation is the command,
<n>,<m>:w name
which writes lines <n> through <m>, inclusive, into a file of the given
name, destroying the file's previous contents, if any.
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.
END-OF-LINE CONVERSIONS
Internally, Calvin uses the Unix<tm> end-of-line convention, that the
single character '\n' indicates the end of a line. Unless otherwise
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -