📄 inter.gml
字号:
:DT.CTRL_B
:DD.Move back one page in the text.
If preceded with a repeat count, you will move back that many pages.
:DT.CTRL_D
:DD.Move down one half page in the text.
If preceded with a repeat count, then you move forward that many lines.
As well, any future
.param CTRL_D
or
.param CTRL_U
commands issued will move that many lines, instead of a half page.
:DT.CTRL_F
:DD.Move forward one page in the text.
If preceded with a repeat count, you will move forward that many pages.
:DT.CTRL_U
:DD.Move up one half page in the text.
If preceded with a repeat count, then you move backwards that many lines.
As well, any future
.param CTRL_U
or
.param CTRL_D
commands issued will move that many lines, instead of a half page.
:DT.j
:DD.Move down through the text.
If preceded with a repeat count, then you move down that many lines.
:DT.k
:DD.Move up through the text.
If preceded with a repeat count, then you move up that many lines.
:DT.G
:DD.Moves to the last line in the file. If preceded with a repeat
count, then you move to that line in the file.
:DT.H
:DD.Move to the top of the current edit window.
If preceded with a repeat count, you move that many lines from the
top of the edit window.
:DT.L
:DD.Move to the bottom of the current edit window.
If preceded with a repeat count, you move that many lines from the
bottom of the edit window.
:DT.M
:DD.Move to the middle of the current edit window.
:eDL.
.*
.exercises
:OL.
:LI.Edit a new file, "atest". Once you have edited this file, add the line:
.millust begin
This is a test line.
.millust end
Once you have done this, copy this line by pressing 'Y'. Press 'p' to paste
in the copy. Press 'p' 28 more times, so that you create a file with
30 lines in it (all just like the first line).
:LI.So that we can more easily see the results, type the following &cmdline:
.millust begin
:%s/^/\# /
.millust end
This is a substitution command. It will replace the start of each of your
lines with the line number. We will learn about the substitution command
in the next chapter. When you are done, you should see a screen similar to
the following:
.figure *depth='2.47' *scale='59' *file='vi018' "ATEST" File Contents
:LI.Press the 'G' key. You will move to the last line of the file.
:LI.Type the following:
.millust begin
15G
.millust end
This will move you to line 15.
:LI.Try using
.param CTRL_F
and
.param CTRL_B
:period.
Notice that they behave just like
.param PAGEUP
and
.param PAGEDOWN
:period.
:LI.Try using 'w' and 'b' to move forward and backwards through words
in the file.
:LI.Try using 'j' and 'k' to cursor up and down in the file.
:LI.Try using 'l' and 'h' to cursor left and right in the file.
:LI.Press the 'H' key. The cursor will move to the top line
in the edit window.
:LI.Press the 'L' key. The cursor will move to the bottom line
in the edit window.
:LI.Try typing some numbers before pressing the 'H' and 'L' keys. For
example, typing
.millust begin
3H
.millust end
will move your cursor to the 3rd line from the top of the edit window.
:LI.Press the 'M' key. The cursor will move to the middle of edit window.
:LI.Press the '$' key. The cursor will move to the end of the current line.
:LI.Press the '0' (zero) key. The cursor will move to the start of the current line.
:LI.Press
.param CTRL_D
:period.
You will move down half a page
:LI.Type the number '2' and then press CTRL_D. Notice that you
only move down 2 lines.
:LI.Press
.param CTRL_D
:period.
You will move down 2 lines.
:LI.Press
.param CTRL_U
:period.
You will move up 2 lines.
:LI.Press 'ZZ' to save the file. This file will be used in later exercises.
:eOL.
.* ******************************************************************
.section 'Saving and Exiting a File Revisited'
.* ******************************************************************
.np
We have already seen in the section
:HDREF refid='savexit'
a number of ways to save and exit your files. These methods included
typing 'ZZ' and using the menus.
.np
There are a number of different &cmdline commands that can be used for
saving and/or quitting your files.
:OL.
:LI.
.keyref quit
("!") or
.param q
("!")
:LI.
.keyref quitall
:LI.
.keyref write
("!") or
.param w
("!")
:LI.
.keyref wq
:LI.
.keyref xit
:eOL.
The
.keyref quit
command is used to exit a file without saving it. If the file has
been modified, the command will fail and the message:
.millust begin
File modified - use :q! to force
.millust end
will be displayed. To quit a modified file, the exclamation point ('!')
is used:
.millust begin
:quit!
.millust end
or
.millust begin
:q!
.millust end
This discards the contents of the current edit buffer.
.np
To quit every file that you are editing, the
.keyref quitall
command is used. If no files have been modified, then you will immediately
exit &edvi.
:period.
If files have been modified, you will be asked to
verify whether or not you really want to exit the editor.
.np
The
.keyref write
command is used to write the current file.
If you specify a file name, the edit buffer will be written to a file
with that name.
.millust begin
:write new.txt
.millust end
writes out a new file with the name
:fname.new.txt:efname.
:period.
.np
If the file name you specify already exists, you will see the message:
.millust begin
File exists - use w! to force
.millust end
To overwrite an existing file, use the exclamation point ('!'):
.millust begin
write! new.txt
.millust end
or
.millust begin
w! new.txt
.millust end
.np
If you are specifying a new file name, you may also specify a line range
to write to that new file. Some examples are:
.millust begin
:1,100 write new.txt - write the first 100 lines to "new.txt".
:50 write a.txt - write line 50 to "a.txt"
.millust end
.np
The
.keyref wq
(write and quit) and the
.keyref xit
(exit) commands both do the same thing. They write out the current file
if it has been modified, and then exit the file. This is the exact
same as typing 'ZZ' in &cmdmode
:period.
.*
.exercises
:OL.
:LI.Edit a file as follows:
.millust begin
vi abc
.millust end
Add the lines:
.millust begin
Line 1.
Line 2.
Line 3.
.millust end
:LI.Enter the &cmdline command
.keyref quit
(remember to press the colon (':') key to bring up the command window).
You will see the message:
.millust begin
File modified - use :q! to force
.millust end
Press
.param CTRL_G
:period.
The message window will indicate the following:
.millust begin
"abc" [modified] line 3 of 3 -- 100% --
.millust end
As you can see, the file has been modified, so you are not
allowed to quit.
.np
:LI.Enter the &cmdline command
.keyref write
:period.
You will see the message:
.millust begin
"abc" 3 lines, 27 bytes
.millust end
This indicates that the file has been written. Now press
.param CTRL_G
:cont.,
and you will see:
.millust begin
"abc" line 3 of 3 -- 100% --
.millust end
Notice that the file no longer is marked as modified once it is
written.
:LI.Try the
&cmdline command
.keyref quit
again. This time, you will be able to quit the file, since
the file has been written, and is no longer marked as modified.
:LI.Re-edit the file "abc". Enter command:
.millust begin
:1,2 w def
.millust end
This will write out a new file called "def".
Now quit &edvi.
:period.
:LI.Edit the file "def". Notice that it contains the lines
.millust begin
Line 1.
Line 2.
.millust end
These are the first two lines of "abc", that you wrote to this file.
Try entering the command:
.millust begin
:write abc
.millust end
You will see the message
.millust begin
File exists - use w! to force
.millust end
Since "abc" already exists, you are not allowed to overwrite it, unless
you specify the exclamation point, as follows:
.millust begin
:write! abc
.millust end
:LI.Re-edit the file "abc". Delete the last line. Press
.param CTRL_G
:cont.,
and you will see that the file is modified. Now, enter the
&cmdline command (remembering to press ':'):
.millust begin
:q!
.millust end
You will exit the file, even though it has been modified.
:LI.Re-edit the file "abc", and delete the last line. Enter the
&cmdline command
.keyref xit
:period.
This will save the file and exit it,
and because you are not editing any other files, you will exit &edvi
:period.
You could also use the command
.keyref wq
to do the same thing. Both of these commands do the same thing as
pressing 'ZZ' while in &cmdmode
:period.
:LI.Start up &edvi as follows:
.millust begin
vi abc def
.millust end
This will edit two files, "abc" and "def". Enter the &cmdline command
.keyref quitall
and you will exit &edvi
:period.
:LI.Repeat the previous example, but add a line to one of the two files.
Now enter the &cmdline command
.keyref quitall
:period.
In this case, you will be prompted with
.millust begin
Files are modified, really exit?
.millust end
Reply with a 'y', and you will exit &edvi, even though files are modified.
:eOL.
.* ******************************************************************
.section 'Using the Mouse'
.* ******************************************************************
.np
You may use the mouse for many things. You may select text, relocate
the cursor, resize a window, move a window, use the scroll bar, or
use the menus.
.np
Text selection will be discussed in the next section. Using menus with
the mouse was discussed in the previous chapter, in the section
:HDREF refid='basmenu'.
:period.
.np
By simply moving your mouse cursor to a location in an edit window
and clicking the left mouse button, the cursor will move to that
position.
.np
By moving your mouse to the top border of an edit window and pressing
down the left mouse button, you can move the window around
by moving your mouse. When you release the button, the window
will move to the new position.
.np
By moving your mouse to the bottom right hand corner of an edit window
(to the vertical two-headed arrow)
and pressing down the left mouse button, you can resize the window by
moving your mouse. When you release the left button, the window
will be redrawn in its new size.
.np
Edit windows have scroll bars which indicate the position in the file and
allow you to position to different portions of the file. The scroll thumb
(the solid block on the scroll bar) indicates the relative location
of your current cursor position in the file. If the scroll thumb is
at the top, then you are on the top line of the file. If it is at
the bottom, then you at the end of the file.
.np
By left-clicking on the single
arrows at the top or the bottom of the scroll bar, the edit window
will scroll up or down a single line. If you hold the left mouse button
down, then the window will scroll continuously.
.np
If you click the left mouse button in the scrollbar region between the
thumb and the top arrow,
you will move up a page in the file you are editing. If you click
the left mouse button below the scroll thumb, you will move down a page
in the file you are editing. If you hold the left mouse button down,
then you will page continuously.
.np
By pressing and holding down the left mouse button on the scroll
thumb, you can set the edit position yourself. As you drag the scroll thumb
up and down, the edit window will be redrawn to show you the corresponding
portion of your file.
.* ******************************************************************
.section 'Selecting Text'
.* ******************************************************************
.np
&edvi has the ability to highlight (select) text, either on an individual
line or a group of lines, and then do various actions on the highlighted
(selected) text.
.np
You may select text with either the keyboard or the mouse. The
keyboard interface is as follows:
:INCLUDE file='textsel.gml'
.np
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -