cmds.gml

来自「开放源码的编译器open watcom 1.6.0版的源代码」· GML 代码 · 共 1,820 行 · 第 1/4 页

GML
1,820
字号
.*
.* (c) Copyright 1992 by WATCOM International Corp.
.*
.* All rights reserved. No part of this publication may be reproduced or
.* used in any form or by any means - graphic, electronic, or mechanical,
.* including photocopying, recording, taping or information storage and
.* retrieval systems - without written permission of WATCOM Publications
.* Limited.
.*
.* Date		By		Reason
.* ----		--		------
.* 31-jul-92	Craig Eisler	initial draft
.*
:CHAPTER id=cmds.Editor Commands
:CMT :SECTION.Introduction
This chapter describes the various editor commands that may be entered.
A command is entered by pressing the colon (':') key while in &cmdmode
:CONT.,
or by selecting the
:HILITE.Enter command
option in the
:HILITE.File
menu.
:P.
To ensure that you are in &cmdmode,
press
:HILITE.ESC
until the mode indicator says
:ILLUST.
Mode: command
:eILLUST.
Once you press the ':' key, the command entry window will appear:
:picture file='cmdenter' text='Command Entry Window'.
This position and size of the command entry window are controlled using
the
:KEYWORD.commandwindow
windowing command (character mode versions of the editor only).
Commands may be up to 512 bytes in length; the command window scrolls.
:P.
There are a special set of commands that may be entered at the command
line for controlling the various windows and menus of &edname.
:PERIOD.
These commands are discussed in the next chapter,
:HILITE.Windows and Menus
:PERIOD.
:P.
The &cmdline has a command history associated with it; the size
of this command history is controlled using the
:KEYWORD.maxclhistory
setting.  As well, the command history is preserved across sessions of
&edname if the
:KEYWORD.historyfile
parameter is set.
:P.
If a command is being executed through a mapped key (see the
:KEYWORD.map
and
:KEYWORD.mapbase
commands later in this chapter), then it can be useful to keep the command
from being added to the history.  By having a "\h" as the first characters
after the ':' character, the command will not be added to the command
history.
:SECTION.Special Keys In The Command Window
Once in the command window, a number of keys have special meaning:
:INCLUDE file='speckeys'.
:SECTION id='lineadd'.Line Addresses
Some commands take a line address range and/or a line address.
A line address is composed of a line number or a special symbol.
As well, '+' and '-' may be used to add or subtract from the current address;
e.g.:
:DEFLIST.
:DEFITEM.5+7
Indicates line 13
:DEFITEM.100-5
indicates line 95
:DEFITEM.99-11+6
indicates line 94
:eDEFLIST.
:P.
Special symbols are:
:DEFLIST.
:DEFITEM.. (dot)
Represents the current line number.
:DEFITEM.$ (dollar)
Represents the last line number.
:DEFITEM.% (percent)
Represents the address range 1,$ (the entire file)
:DEFITEM.# (pound)
Represents the current selected region
:DEFITEM.'a (front quote)
Indicates the line with the mark 'a' set; marks 'a' through 'z'
may be used.
:DEFITEM./regexp/
Indicates the first line following the current line that has
the regular expression
:CMDPARM.regexp
:PERIOD.
If
:CMDPARM.regexp
is not specified, then the last regular expression search is used.
:DEFITEM.?regexp?
Indicates the first line previous to the current line that has
the regular expression
:CMDPARM.regexp
:PERIOD.
If
:CMDPARM.regexp
is not specified, then the last regular expression search is used.
:eDEFLIST.
:P.
For more information on regular expressions, see the chapter
:HDREF refid='rxchap'.
:PERIOD.
:P.
If a line address is not specified, then the current line is assumed.
If + or - are the first character, then they are assumed to operate
on the current line number; e.g. specifying +1 takes you forward one
line in the file.
:P.
A line address range is two line addresses separated by a comma; these
indicate the start and end of the line address range.
:SUBSECT.Line Address Examples
:DEFLIST.
:DEFITEM..-5
5 lines before the current line
:DEFITEM.1,5
lines 1 to 5.
:DEFITEM..-10,.+10
10 lines before the current line to 10 lines past the current line
:DEFITEM.$-5
5 lines before the last line in the file
:DEFITEM.%
all lines
:DEFITEM.#
all lines in the currently selected region
:DEFITEM.'a,.
line with mark 'a' to current line.
:DEFITEM./foo/
the first line after the current line containing 'foo'
:DEFITEM.'z+5,$-10
5 lines past line with mark 'z' to 10 lines before the end of the file.
:DEFITEM./foo/+5,/bar/-1
5 lines past line next line containing 'foo' to
 1 line before the line containing 'bar'.
:eDEFLIST.
:eSUBSECT.
:SECTION.Commands
:INCLUDE file='cmdintro'.
For example, in its syntax model,
the edit command is specified as "Edit", indicating that the "e", "ed",
"edi", and "edit" are acceptable abbreviations (and that "e" is the shortest
of them).
:P.
Some commands are noted as "
:KEYWORD pc=1.EX mode
only".  This means that the command
is not available from the normal &cmdline;
it may only be used from an editor
:KEYWORD.script
or from
:KEYWORD pc=1.EX mode
(which is entered by pressing 'Q' in &cmdmode).

:FNLIST.Commands

:FUNC.> (Shift Right)
:SYNTAX.<line_range> >
This command shifts the specified line range &range to the
right
:KEYWORD.shiftwidth
spaces, inserting necessary leading tabs if
:KEYWORD.realtabs
is specified.
:EXAMPLE.1,. >
Shifts from first line to current line to the right
:KEYWORD.shiftwidth
spaces.
:SEEALSO.
:SEE.<
:SEE key=1.>
:SEE key=1.<
:eSEEALSO.
:eFUNC.

:FUNC.< (Shift Left)
:SYNTAX.<line_range> <
This command shifts the specified line range &range to the
left
:KEYWORD.shiftwidth
spaces.
:EXAMPLE..,$ <
Shifts entire file
:KEYWORD.shiftwidth
spaces to the left.
:SEEALSO.
:SEE.>
:SEE key=1.>
:SEE key=1.<
:eSEEALSO.
:eFUNC.

:FUNC.! (Filter)
:SYNTAX.<line_range> ! <cmd>
If &range is specified, then the lines are run through the specified
system command &parm1 (the command must get its input from standard in and
write its output to standard out) and replaces the lines with the output 
of the command.
:BLANKLINE.
If no range is specified, then the system command
&parm1 is run.  If &parm1 is not specified, then an operating
system shell is started.
:BLANKLINE.
The global variable %(Sysrc) contains the return code
from the last system command, and %(Syserr) contains
the errno value.
:EXAMPLE.1,$ ! sort
Takes all lines in the current edit buffer and runs them through the
:ITALICS.sort
command.  The lines are then replaced with the output of the sort
command.
:EXAMPLE.! dir
Executes the system
:ITALICS.dir
command.  After
:ITALICS.dir
is finished executing, you are prompted to press a key before returning
to the editor.
:EXAMPLE.!
Temporarily leaves &edname and enters an operating system command shell.
:SEEALSO.
:SEE.shell
:SEE key=1.!
:eSEEALSO.
:eFUNC.

:FUNC.ABBREV
:SYNTAX.* ABbrev <short> <long>
Create an abbreviation of &parm1 for &parm2.
:PERIOD.
Whenever &parm1 is typed
as a word during &tinsmode, it is expanded to &parm2.
:PERIOD.
:KEYWORD.unabbrev
is used to remove the abbreviation.
:EXAMPLE.abbrev wh while(
Whenever
:ITALICS.wh
is entered as a word, the word
:ITALICS.while(
is substituted.
:SEEALSO.
:SEE.unabbrev
:eSEEALSO.
:eFUNC.

:FUNC.ALIAS
:SYNTAX.* ALias <alias> <data>
Creates an &cmdline alias of &parm1 for &parm2.
:PERIOD.
Whenever &parm1
is typed on the &cmdline, the full command &parm2 is substituted.
:KEYWORD.unalias
is used to remove the abbreviation.
:EXAMPLE.alias ai set autoindent
Whenever
:ITALICS.ai
is entered on the &cmdline, the command
:ITALICS.set autoindent
is executed.
:SEEALSO.
:SEE.unalias
:eSEEALSO.
:eFUNC.

:FUNC.APPEND
:SYNTAX.<line_num> Append
Appends source lines after line &range.
:PERIOD.
Append is terminated when a line
with nothing but a dot ('.') is entered.
:EXMODE.
:SEEALSO.
:SEE.change
:SEE.insert
:eSEEALSO.
:eFUNC.

:FUNC.CASCADE
:SYNTAX.* CASCADE
Causes all edit buffer windows to cascade (overlap each other with top
border of each visible).
:SEEALSO.
:SEE.maximize
:SEE.minimize
:SEE.movewin
:SEE.resize
:SEE.size
:SEE.tile
:eSEEALSO.
:eFUNC.

:FUNC.CD
:SYNTAX.* CD <dir>
Changes current working directory to &parm1.
:PERIOD.
If &parm1 is not specified,
then the current directory is displayed in the message window.  &parm1
may be specified with drive and path.
:EXAMPLE.cd c:\tmp
Changes to the \tmp directory of the c drive
:EXAMPLE.cd
Display the current working directory
:eFUNC.

:FUNC.CHANGE
:SYNTAX.<line_range> Change
Deletes the line range &parm1, and replaces the range with inputted
source lines.  The input of text is terminated when a line with
nothing on it but a dot ('.') is entered.
:EXMODE.
:SEEALSO.
:SEE.append
:SEE.insert
:eSEEALSO.
:eFUNC.

:FUNC.COMPILE
:SYNTAX.* COMPile '"-a"' '"-A"' <script> <result>
Compiles the editor
:KEYWORD.script
&parm3
:PERIOD.
:BLANKLINE.
If
:CMDPARM.-a
is specified,
all local variables are translated at compile time (rather
than at run time) - this is useful for the
:KEYWORD.configuration script
:PERIOD.
:BLANKLINE.
If
:CMDPARM.-A
is specified, all variables (both local and global)
are translated at compile time.
:BLANKLINE.
The file will be compiled
into a file with the same name as the script and the extension ._vi.,
unless &parm4 is specified.
:BLANKLINE.
For information on editor
:KEYWORD.scripts
:CONT.,
see the chapter
:HDREF refid='scripts'.
:PERIOD.
:EXAMPLE.comp -a ed.cfg
Compiles the default
:KEYWORD.configuration script
:ITALICS.ed.cfg
and expands all local variables to any values assigned to them in
the
:KEYWORD.script
:PERIOD.
The compiled
:KEYWORD.script
file
:ITALICS.ed._vi
is generated.
:BLANKLINE.
If any errors occur while compiling, a file with the the same name
as the script and the extension .err
is created.
:EXAMPLE.comp test.vi test.out
Compiles the
:KEYWORD.script
:ITALICS.test.vi
and generates the compiled
:KEYWORD.script
file
:ITALICS.test.out
:PERIOD.
:SEEALSO.
:SEE.load
:SEE.source
:eSEEALSO.
:eFUNC.

:FUNC.COMPRESS
:SYNTAX.* COMpress
Replaces spaces in the current edit buffer with 
tabs.  Single spaces are not replaced with a tab, and spaces inside
a quoted string are not replaced with a tab.
:eFUNC.

:FUNC.COPY
:SYNTAX.<line_range> COpy <line_number>
Copies the specified range of lines &range after the line &parm1.
:PERIOD.
:EXAMPLE.% copy $
Copies the entire file and places the lines after the last line
in the file.
:EXAMPLE.1,. copy .
Copies all lines from the beginning of the file to the current line
and places the lines after the current line.
:eFUNC.

:FUNC.DATE
:SYNTAX.* DAte
Display the current time and date in the message window.
:eFUNC.

:FUNC.DELETE
:SYNTAX.<line_range> Delete <buffer>
Deletes the specified line range &range.
:PERIOD.
:BLANKLINE.
If &parm1 is not specified,
the text is deleted into the active &copybuffer
:PERIOD.
:BLANKLINE.
If &parm1 ('1'-'9', or 'a'-'z') is specified, the text is deleted into
that &copybuffer
:PERIOD.
:BLANKLINE.
The
:KEYWORD.put
command may be used to place contents of a &copybuffer into the file.
:EXAMPLE.% d
Deletes all lines into the active &copybuffer
:PERIOD.
:EXAMPLE.1,10 d a
Deletes lines 1 to 10 into the named &copybuffer
:ITALICS.a
:PERIOD.
:SEEALSO.
:SEE.move
:SEE.put
:SEE.yank
:SEE key=1.d
:SEE key=1.p
:SEE key=1.P
:SEE key=1.y
:eSEEALSO.
:eFUNC.

:FUNC.ECHO
:SYNTAX.* ECHO <line> <msg>
Echos the message &parm2 on line &parm1 of the message window.
:BLANKLINE.
If &parm1 is specified as
:ITALICS.off
:CONT.,
then nothing is echoed into the message window from then on.
:BLANKLINE.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?