📄 inter.gml
字号:
.param CTRL_F1
through
.param CTRL_F9
in &cmdmode.
:period.
When you do this, a message appears showing you which buffer
has been selected, how many lines/characters are in the buffer, and the first
line of the buffer.
.np
There are also 26 named buffers, 'a' through 'z'. The contents of
these buffers is constant over the life of your editing session. They
retain their contents until you update them.
.np
For more information on copy buffers, see the section
:HDREF refid='cpybuff'
in the chapter
:HDREF page=no refid='modes'
:period.
.np
There is also a
.keyref delete
&cmdline command and a
.keyref yank
&cmdline command for deleting and yanking text. These commands only
operate on line ranges. Their syntax is:
.millust begin
<.range>. delete <."?>.
<.range>. yank <."?>.
.millust end
The
.param <."?>.
indicates a ©buffer,
and
.param <.range>.
indicates a line range. If no line range is specified, then the
current line is assumed. Some examples are:
.millust begin
:1,5 delete - delete lines 1 to 5
:1,$ yank "a - copy all lines into buffer 'a'
:d - deletes the current line
.millust end
.np
In the section
:HDREF refid='scap'.
in the previous chapter, you learned about the small 'p' and the
capital 'p' ('P') &cmdmode commands to put (paste) copied or deleted
text into the edit buffer. Remember, small 'p' is used to paste after the
current cursor position, and capital 'p' ('P') is use to paste before
the current cursor position.
.np
If what you deleted or yanked was a sequence of characters on a single line,
then these characters are inserted into the current line when you paste.
If you deleted or yanked whole lines, then those lines are inserted
around the current line when you paste.
.np
The put (paste) &cmdline commands accept a ©buffer as the buffer
to paste out of. The default is the active ©buffer, but any
buffer can be specified. Once again,
.param <."?>.
indicates a ©buffer:
.millust begin
<."?>.p
<."?>.P
.millust end
.np
As well, there is a &cmdline command for pasting text: the
.keyref put
command. The syntax is:
.millust begin
<.line>. put <.!>. <."?>.
.millust end
If the line
.param <.line>.
is specified, then the buffer is pasted around the specified line instead
of the current line.
.np
If the exclamation mark is specified, then contents of the ©buffer
are pasted before the specified line. Otherwise, the contents of the
©buffer are pasted after the specified line.
.np
The
.param <."?>.
is an optional ©buffer.
:period.
If it is not specified, then the active ©buffer is used. The double
quotes (") must be specified.
.np
Deleting text is discussed in more detail in the section
:HDREF refid='deltext'.
in the chapter
:HDREF page=no refid='modes'.
:period.
.np
Copying text is discussed in more detail in the section
:HDREF refid='cpytext'.
in the chapter
:HDREF page=no refid='modes'.
:period.
.*
.exercises
:OL.
:LI.Edit the file "atest" created in the Exercises section of
:HDREF refid='maiaf'
:period.
Press 'dd'. This will delete the first line of the file.
:LI.Press 'dw'. This will delete the first word of the line.
:LI.Press 'd$'. This will delete to the end of the line.
:LI.Press 'dj'. This will delete the current line and the next line.
:LI.Press '2dw'. This will delete the first two words of the current line:
.millust begin
04 This is a test line.
.millust end
leaving you with
.millust begin
is a test line.
.millust end
:LI.Press '2w'. This will move you to the letter 't' in "test". Press
capital p ('P').
The 2 words you deleted will be inserted before the 't':
.millust begin
is a 04 This test line.
.millust end
:LI.Type the following &cmdmode keys:
.millust begin
"add
.millust end
You will see the message:
.millust begin
1 lines deleted into buffer a
.millust end
:LI.Press 'p'. Note that you inserted the two words you deleted before
into the current line.
:LI.Type:
.millust begin
"ap
.millust end
This will insert the contents of buffer 'a' (line line you deleted) after
the current line.
:LI.Type the following:
.millust begin
2"byy
.millust end
This will copy the next two lines into buffer "b". You will see the message
.millust begin
2 lines yanked into buffer b
.millust end
:LI.Type:
.millust begin
"bP
.millust end
This will insert the two lines you yanked before the current line.
:LI.Type
.millust begin
3"zyw
.millust end
This will yank three words into ©buffer 'z'.
:INCLUDE file='exerquit'.
:eOL.
.* ******************************************************************
.section 'Altering Text'
.* ******************************************************************
.np
You could change text by deleting the text and then entering insert mode.
However, &edvi provides a special method for doing both of these
things at once. By pressing the 'c' key in &cmdmode, you enter the
change sub-mode. You will see the mode line indicate:
.millust begin
Mode: change
.millust end
If you are changing characters on a line, the characters will be highlighted.
If you press the
.param ESC
key, the change will be cancelled.
Once you type a character, the characters will be deleted and you will
enter &tinsmode.
:period.
.np
If you are changing whole lines, the lines are deleted and you enter
&tinsmode.
:period.
.np
Once you have entered the change sub-mode, you can then specify one of the
following operations:
:INCLUDE file='operlist'.
Some examples are:
.millust begin
cw - change current word
c$ - change to the end of the current line
.millust end
.np
You can also specify an optional repeat count before the change command.
This will cause the change command to be repeated that many times.
For example:
.millust begin
2cw - change two words
3cc - change three lines
.millust end
.np
The changing of text is discussed in greater detail in the section
:HDREF refid='cmchg'.
of the chapter
:HDREF page=no refid='modes'
:period.
.*
.exercises
:OL.
:LI.Edit the file "atest" created in the Exercises section of
:HDREF refid='maiaf'
:period.
Type 'cw'. This first word "01" will be highlighted. Press
.param ESC
:period.
The word will return to normal, and nothing will happen.
:LI.Type 'cw' again. This time, type the following:
.millust begin
This is new text.
.millust end
and press the
.param ESC
key to exit &tinsmode
:period.
Your original line:
.millust begin
01 This is a test line.
.millust end
will now be:
.millust begin
This is new text. This is a test line.
.millust end
:LI.Type '2cc'. The first two lines will be deleted, and you will enter
text insertion mode. Type the following:
.millust begin
This is more new text.
.millust end
:LI.Return to &cmdmode by pressing the
.param ESC
key. Cursor to the letter 'i' in the word "is" and type 'c$'. This
will highlight
from the letter 'i' to the end of line. Enter the
text:
.millust begin
This is more new text.
.millust end
:INCLUDE file='exerquit'.
:eOL.
.* ******************************************************************
.section 'Undo and Redo'
.* ******************************************************************
.np
&edvi has an unlimited undo capacity (constrained only by memory and
disk space). Every change that you make
to a file is remembered, and can be undone in the reverse order that
you made the changes.
.np
A change can be undone by pressing the letter 'u' while in
&cmdmode
:period.
You can undo further changes by pressing 'u' repeatedly.
.np
If you undo a change you wanted to keep, you can
.keyword redo
it by pressing capital 'u' ('U'). Each time
you press 'U', an undo is re-done. Once you undo changes, you cannot
redo them after you modify the file.
.np
The &cmdline command for undoing changes has the following syntax:
.millust begin
undo
.millust end
If you specify an exclamation point ('!') after the
.keyref undo
keyword, then you will do a redo
instead of an undo:
.millust begin
undo!
.millust end
.np
See the section
:HDREF refid='cmundo'
in the chapter
:HDREF page=no refid='modes'
for more information.
.*
.exercises
:OL.
:LI.Edit the file "atest" created in the Exercises section of
:HDREF refid='maiaf'
:period.
Delete the first line, delete the second line, then delete the third
line (one at a time). Then, press 'u' in command mode. The third
line will come back.
:LI.Press 'u' again. The second line will come back.
:LI.Enter the &cmdline command:
.millust begin
:undo
.millust end
The first line will come back.
:LI.Enter the &cmdline command
.millust begin
:undo
.millust end
again. This undo command cannot do anything, since you have already
undo all the changes to your file. You will see the message
.millust begin
No more undos
.millust end
appear.
:LI.Press the capital u ('U') key in &cmdmode.
:period.
The first line will now disappear, as you are undoing your undo.
:LI.Press 'U' again. The second line will disappear.
:LI.Enter the &cmdline command (remember to press ':'):
.millust begin
undo!
.millust end
The third line will disappear.
:LI.Enter the &cmdline command:
.millust begin
undo!
.millust end
You will see the message:
.millust begin
No more undos
.millust end
:eOL.
.* ******************************************************************
.section 'Repeating Edit Operations'
.* ******************************************************************
.np
When you enter a &cmdmode command to modify your file
you can re-execute the sequence by pressing the dot ('.') key.
.np
For example, suppose you entered the &cmdmode command:
.millust begin
3dd
.millust end
to delete 3 lines. If you press '.' after this, you will delete another
3 lines.
.np
There are two useful extension to this as well. &edvi has concepts
known as
.keyword memorize mode
and
.keyword alternate memorize mode
:period.
You enter memorize mode
by pressing the letter 'm' (also used to set a mark) followed by a dot ('.').
You will then see the message
.millust begin
Memorize Mode started
.millust end
From this point forward, every key that you type is memorized. When you
are done memorizing, you can then press the dot ('.') key while in &cmdmode,
and this ends memorize mode.
You will see the message:
.millust begin
Memorize Mode ended
.millust end
.np
Once you have memorized a key sequence, you can re-execute it by pressing dot ('.').
This will cause &edvi to behave as if all the keys you memorized were
being typed by you again.
.np
The memorized sequence will be lost the next time you
change the text other than with '.'. To memorize a sequence that will
always be remembered, you can use
.keyword alternate memorize mode
:period.
This mode is used the same way as memorize mode,
only you use an equals sign ('=') instead of a dot ('.').
.*
.exercises
:OL.
:LI.Edit the file "atest" from the Exercises section of
:HDREF refid='maiaf'
:period.
Delete the first two lines by typing the &cmdmode command:
.millust begin
2dd
.millust end
Now press the dot ('.') key. Two more lines will be deleted.
:LI.Move to the first column of the first line. Type the &cmdmode command:
.millust begin
m.
.millust end
This will start you in memorize mode. Now, type:
.millust begin
dwjdwj.
.millust end
This deletes the word on the first line, goes down to the next line,
deletes another word on the next line, and goes down one more line.
The final dot ('.') terminates memorize mode.
:LI.Now, press dot ('.'). This will delete the first word of the next
two lines.
:INCLUDE file='exerquit'.
:eOL.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -