inter.gml
来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 1,140 行 · 第 1/3 页
GML
1,140 行
:HILITE.CTRL_D
commands issued will move that many lines, instead of a half page.
:DEFITEM.j
Move down through the text.
If preceded with a repeat count, then you move down that many lines.
:DEFITEM.k
Move up through the text.
If preceded with a repeat count, then you move up that many lines.
:DEFITEM.G
Moves to the last line in the file. If preceded with a repeat
count, then you move to that line in the file.
:DEFITEM.H
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.
:DEFITEM.L
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.
:DEFITEM.M
Move to the middle of the current edit window.
:eDEFLIST.
:EXERCISES.
:OL.
:LI.Edit a new file, "atest". Once you have edited this file, add the line:
:ILLUST.
This is a test line.
:eILLUST.
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:
:ILLUST.
:%s/^/\# /
:eILLUST.
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:
:PICTURE file='atest' text='"ATEST" File Contents '.
:LI.Press the 'G' key. You will move to the last line of the file.
:LI.Type the following:
:ILLUST.
15G
:eILLUST.
This will move you to line 15.
:LI.Try using
:HILITE.CTRL_F
and
:HILITE.CTRL_B
:PERIOD.
Notice that they behave just like
:HILITE.PAGEUP
and
:HILITE.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
:ILLUST.
3H
:eILLUST.
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
:HILITE.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
:HILITE.CTRL_D
:PERIOD.
You will move down 2 lines.
:LI.Press
:HILITE.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.
:eEXERCISES.
:SECTION.Saving and Exiting a File Revisited
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.
:P.
There are a number of different &cmdline commands that can be used for
saving and/or quitting your files.
:OL.
:LI.:KEYWORD.quit
("!") or :CMDPARM.q
("!")
:LI.:KEYWORD.quitall
:LI.:KEYWORD.write
("!") or :CMDPARM.w
("!")
:LI.:KEYWORD.wq
:LI.:KEYWORD.xit
:EOL.
The
:KEYWORD.quit
command is used to exit a file without saving it. If the file has
been modified, the command will fail and the message:
:ILLUST.
File modified - use :q! to force
:eILLUST.
will be displayed. To quit a modified file, the exclamation point ('!')
is used:
:ILLUST.
:quit!
:eILLUST.
or
:ILLUST.
:q!
:eILLUST.
This discards the contents of the current edit buffer.
:P.
To quit every file that you are editing, the
:KEYWORD.quitall
command is used. If no files have been modified, then you will immediately
exit &edname.
:PERIOD.
If files have been modified, you will be asked to
verify whether or not you really want to exit the editor.
:P.
The
:KEYWORD.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.
:ILLUST.
:write new.txt
:eILLUST.
writes out a new file with the name
:ITALICS new.txt
:PERIOD.
:P.
If the file name you specify already exists, you will see the message:
:ILLUST.
File exists - use w! to force
:eILLUST.
To overwrite an existing file, use the exclamation point ('!'):
:ILLUST.
write! new.txt
:eILLUST.
or
:ILLUST.
w! new.txt
:eILLUST.
:P.
If you are specifying a new file name, you may also specify a line range
to write to that new file. Some examples are:
:ILLUST
:1,100 write new.txt - write the first 100 lines to "new.txt".
:50 write a.txt - write line 50 to "a.txt"
:eILLUST.
:P.
The
:KEYWORD.wq
(write and quit) and the
:KEYWORD.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:
:ILLUST.
vi abc
:eILLUST.
Add the lines:
:ILLUST.
Line 1.
Line 2.
Line 3.
:eILLUST.
:LI.Enter the &cmdline command
:KEYWORD.quit
(remember to press the colon (':') key to bring up the command window).
You will see the message:
:ILLUST.
File modified - use :q! to force
:eILLUST.
Press
:HILITE.CTRL_G
:PERIOD.
The message window will indicate the following:
:ILLUST.
"abc" [modified] line 3 of 3 -- 100% --
:eILLUST.
As you can see, the file has been modified, so you are not
allowed to quit.
:P.
:LI.Enter the &cmdline command
:KEYWORD.write
:PERIOD.
You will see the message:
:ILLUST.
"abc" 3 lines, 27 bytes
:eILLUST.
This indicates that the file has been written. Now press
:HILITE.CTRL_G
:CONT.,
and you will see:
:ILLUST.
"abc" line 3 of 3 -- 100% --
:eILLUST.
Notice that the file no longer is marked as modified once it is
written.
:LI.Try the
&cmdline command
:KEYWORD.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:
:ILLUST.
:1,2 w def
:eILLUST.
This will write out a new file called "def".
Now quit &edname.
:PERIOD.
:LI.Edit the file "def". Notice that it contains the lines
:ILLUST.
Line 1.
Line 2.
:eILLUST.
These are the first two lines of "abc", that you wrote to this file.
Try entering the command:
:ILLUST.
:write abc
:eILLUST.
You will see the message
:ILLUST.
File exists - use w! to force
:eILLUST.
Since "abc" already exists, you are not allowed to overwrite it, unless
you specify the exclamation point, as follows:
:ILLUST.
:write! abc
:eILLUST.
:LI.Re-edit the file "abc". Delete the last line. Press
:HILITE.CTRL_G
:CONT.,
and you will see that the file is modified. Now, enter the
&cmdline command (remembering to press ':'):
:ILLUST
:q!
:eILLUST.
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
:KEYWORD.xit.
This will save the file and exit it,
and because you are not editing any other files, you will exit &edname
:PERIOD.
You could also use the command
:KEYWORD.wq
to do the same thing. Both of these commands do the same thing as
pressing 'ZZ' while in &cmdmode
:PERIOD.
:LI.Start up &edname as follows:
:ILLUST.
vi abc def
:eILLUST.
This will edit two files, "abc" and "def". Enter the &cmdline command
:KEYWORD.quitall
and you will exit &edname
:PERIOD.
:LI.Repeat the previous example, but add a line to one of the two files.
Now enter the &cmdline command
:KEYWORD.quitall
:PERIOD.
In this case, you will be prompted with
:ILLUST.
Files are modified, really exit?
:eILLUST.
Reply with a 'y', and you will exit &edname, even though files are modified.
:eOL.
:eEXERCISES.
:SECTION.Using the Mouse
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.
:P.
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.
:P.
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.
:P.
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.
:P.
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.
:P.
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.
:P.
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.
:P.
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.
:P.
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
&edname 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.
:P.
You may select text with either the keyboard or the mouse. The
keyboard interface is as follows:
:INCLUDE file='textsel.gml'
:P.
Once text selection has been started, then any movement command may
be used to expand or shrink the selected region. Multiple line selections
always select complete lines. A portion of a single line can be
selected (i.e. a word) by growing the selection left or right. A portion
of a line is called a column region and a multiple line selection is
called a line region.
:P.
You can select text with the mouse by holding down the right or left mouse
button, and moving the mouse up and down or left and right.
When using the right button, a selection menu will appear after the mouse
button is released , from which you choose what
you wish to do with the selected text.
:P.
If you highlight a region by holding down the left button and moving
the mouse, then releasing the button has no effect
(the region simply remains highlighted). This region may then be operated
on from the &cmdline, using different &cmdmode commands, or by right-clicking
the mouse in the selected region.
:P.
If you click the right mouse button (right-click) while the mouse cursor
is in a highlighted (selected) set of lines, then a selection menu
for the lines appears. If you right-click in a selected group of characters
on a single line (a column region) then a selection menu for that column
region appears. The two menus are different. You may also bring up
these menus by pressing the underscore
('_') key.
:P.
If you click the right mouse button (right-click) in an unselected region,
the current word will be highlighted and the selection menu will appear.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?