📄 cmds.gml
字号:
.****************************************************************************
.*
.* Open Watcom Project
.*
.* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
.*
.* ========================================================================
.*
.* This file contains Original Code and/or Modifications of Original
.* Code as defined in and that are subject to the Sybase Open Watcom
.* Public License version 1.0 (the 'License'). You may not use this file
.* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
.* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
.* provided with the Original Code and Modifications, and is also
.* available at www.sybase.com/developer/opensource.
.*
.* The Original Code and all software distributed under the License are
.* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
.* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
.* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
.* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
.* NON-INFRINGEMENT. Please see the License for the specific language
.* governing rights and limitations under the License.
.*
.* ========================================================================
.*
.* Description: Root file of VI documentation.
.*
.* Date By Reason
.* ---- -- ------
.* 31-jul-92 Craig Eisler initial draft
.* 01-oct-05 L. Haynes reformatted for hlp, figures
.*
.****************************************************************************/
.*
.chap *refid=cmds 'Editor Commands'
:cmt. .if &e'&dohelp eq 0 .do begin
:cmt. . .section 'Introduction'
:cmt. .do end
.np
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
.keyword Enter command
option in the
.keyword File
menu.
.np
To ensure that you are in &cmdmode,
press
.keyword ESC
until the mode indicator says
.millust begin
Mode: command
.millust end
Once you press the ':' key, the command entry window will appear:
.figure *depth='2.47' *scale='59' *file='vi028' Command Entry Window
This position and size of the command entry window are controlled using
the
.keyref commandwindow
windowing command (character mode versions of the editor only).
Commands may be up to 512 bytes in length; the command window scrolls.
.np
There are a special set of commands that may be entered at the command
line for controlling the various windows and menus of &edvi.
:period.
These commands are discussed in the next chapter,
:HDREF refid=winmenu.
:period.
.np
The &cmdline has a command history associated with it; the size
of this command history is controlled using the
.keyref maxclhistory
setting. As well, the command history is preserved across sessions of
&edvi. if the
.keyref historyfile
parameter is set.
.np
If a command is being executed through a mapped key (see the
.keyref map
and
.keyref 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'
.* ******************************************************************
.np
Once in the command window, a number of keys have special meaning:
:INCLUDE file='speckeys'.
.* ******************************************************************
.section *refid=lineadd 'Line Addresses'
.* ******************************************************************
.np
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.:
.*
:DL break.
.*
:DT.5+7
:DD.Indicates line 13
:DT.100-5
:DD.indicates line 95
:DT.99-11+6
:DD.indicates line 94
.*
:eDL.
.*
.np
Special symbols are:
.*
:DL break.
.*
:DT.. (dot)
:DD.Represents the current line number.
:DT.$ (dollar)
:DD.Represents the last line number.
:DT.% (percent)
:DD.Represents the address range 1,$ (the entire file)
:DT.# (pound)
:DD.Represents the current selected region
:DT.'a (front quote)
:DD.Indicates the line with the mark 'a' set; marks 'a' through 'z'
may be used.
:DT./regexp/
:DD.Indicates the first line following the current line that has
the regular expression
.var regexp
:period.
If
.param regexp
is not specified, then the last regular expression search is used.
:DT.?regexp?
:DD.Indicates the first line previous to the current line that has
the regular expression
.param regexp
:period.
If
.param regexp
is not specified, then the last regular expression search is used.
.*
:eDL.
.*
.np
For more information on regular expressions, see the chapter
:HDREF refid='rxchap'.
:period.
.np
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.
.np
A line address range is two line addresses separated by a comma; these
indicate the start and end of the line address range.
.*
.beglevel
.* ******************************************************************
.section 'Line Address Examples'
.* ******************************************************************
:DL break.
.*
:DT..-5
:DD.5 lines before the current line
:DT.1,5
:DD.lines 1 to 5.
:DT..-10,.+10
:DD.10 lines before the current line to 10 lines past the current line
:DT.$-5
:DD.5 lines before the last line in the file
:DT.%
:DD.all lines
:DT.#
:DD.all lines in the currently selected region
:DT.'a,.
:DD.line with mark 'a' to current line.
:DT./foo/
:DD.the first line after the current line containing 'foo'
:DT.'z+5,$-10
:DD.5 lines past line with mark 'z' to 10 lines before the end of the file.
:DT./foo/+5,/bar/-1
:DD.5 lines past line next line containing 'foo' to
1 line before the line containing 'bar'.
.*
:eDL.
.*
.endlevel
.* ******************************************************************
.section 'Commands'
.* ******************************************************************
.np
: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).
.np
Some commands are noted as "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 EX mode
(which is entered by pressing 'Q' in &cmdmode).
.*
.fnlist begin Commands
.*
.begfunc >. '(Shift Right)'
.syntx <.line_range>. >.
.begdescr
This command shifts the specified line range &range to the
right
.keyref shiftwidth
spaces, inserting necessary leading tabs if
.keyref realtabs 1
is specified.
.enddescr
.xmplsect begin
.begxmpl 1,. >.
Shifts from first line to current line to the right
.keyref shiftwidth
spaces.
.endxmpl
.xmplsect end
.alsosee begin
.seethis <.
:cmt. .seethis *key=1 >.
:cmt. .seethis *key=1 <.
.alsosee end
.endfunc
.begfunc <. '(Shift Left)'
.syntx <.line_range>. <.
.begdescr
This command shifts the specified line range &range to the
left
.keyref shiftwidth
spaces.
.enddescr
.xmplsect begin
.begxmpl .,$ <.
Shifts entire file
.keyref shiftwidth
spaces to the left.
.endxmpl
.xmplsect end
.alsosee begin
.seethis >.
:cmt. .seethis *key=1 >.
:cmt. .seethis *key=1 <.
.alsosee end
.endfunc
.begfunc ! '(Filter)'
.syntx <.line_range>. ! <.cmd>.
.begdescr
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.
.np
If no range is specified, then the system command
&parm1 is run. If &parm1 is not specified, then an operating
system shell is started.
.np
The global variable %(Sysrc) contains the return code
from the last system command, and %(Syserr) contains
the errno value.
.enddescr
.xmplsect begin
.begxmpl 1,$ ! sort
Takes all lines in the current edit buffer and runs them through the
.param sort
command. The lines are then replaced with the output of the sort
command.
.endxmpl
.begxmpl ! dir
Executes the system
.param dir
command. After
.param dir
is finished executing, you are prompted to press a key before returning
to the editor.
.endxmpl
.begxmpl !
Temporarily leaves &edvi. and enters an operating system command shell.
.endxmpl
.xmplsect end
.alsosee begin
.seethis shell
:cmt. .seethis *key=1 !
.alsosee end
.endfunc
.begfunc ABBREV
.syntx * ABbrev <.short>. <.long>.
.begdescr
Create an abbreviation of &parm1 for &parm2.
:period.
Whenever &parm1 is typed
as a word during &tinsmode, it is expanded to &parm2.
:period.
.keyref unabbrev
is used to remove the abbreviation.
.enddescr
.xmplsect begin
.begxmpl abbrev wh while(
Whenever
.param wh
is entered as a word, the word
.param while(
is substituted.
.endxmpl
.xmplsect end
.alsosee begin
.seethis unabbrev
.alsosee end
.endfunc
.begfunc ALIAS
.syntx * ALias <.alias>. <.data>.
.begdescr
Creates an &cmdline alias of &parm1 for &parm2.
:period.
Whenever &parm1
is typed on the &cmdline, the full command &parm2 is substituted.
.keyref unalias
is used to remove the abbreviation.
.enddescr
.xmplsect begin
.begxmpl alias ai set autoindent
Whenever
.param ai
is entered on the &cmdline, the command
.param set autoindent
is executed.
.endxmpl
.xmplsect end
.alsosee begin
.seethis unalias
.alsosee end
.endfunc
.begfunc APPEND
.syntx <.line_num>. Append
.begdescr
Appends source lines after line &range.
:period.
Append is terminated when a line
with nothing but a dot ('.') is entered.
.exmode
.enddescr
.alsosee begin
.seethis change
.seethis insert
.alsosee end
.endfunc
.begfunc CASCADE
.syntx * CASCADE
.begdescr
Causes all edit buffer windows to cascade (overlap each other with top
border of each visible).
.enddescr
.alsosee begin
.seethis maximize
.seethis minimize
.seethis movewin
.seethis resize
.seethis size
.seethis tile
.alsosee end
.endfunc
.begfunc CD
.syntx * CD <.dir>.
.begdescr
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.
.enddescr
.xmplsect begin
.begxmpl cd c:\tmp
Changes to the \tmp directory of the c drive
.endxmpl
.begxmpl cd
Display the current working directory
.endxmpl
.xmplsect end
.endfunc
.begfunc CHANGE
.syntx <.line_range>. Change
.begdescr
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
.enddescr
.alsosee begin
.seethis append
.seethis insert
.alsosee end
.endfunc
.begfunc COMPILE
.syntx * COMPile '"-a"' '"-A"' <.script>. <.result>.
.begdescr
Compiles the editor script &parm3
:period.
.np
If
.param -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.
.np
If
.param -A
is specified, all variables (both local and global)
are translated at compile time.
.np
The file will be compiled
into a file with the same name as the script and the extension ._vi.,
unless &parm4 is specified.
.np
For information on editor
.keyword scripts
:cont.,
see the chapter
:HDREF refid='scripts'.
:period.
.enddescr
.xmplsect begin
.begxmpl comp -a ed.cfg
Compiles the default
.keyword configuration script
:fname.ed.cfg:efname.
and expands all local variables to any values assigned to them in
the script. The compiled script file
:fname.ed._vi:efname.
is generated.
.np
If any errors occur while compiling, a file with the the same name
as the script and the extension .err
is created.
.endxmpl
.begxmpl comp test.vi test.out
Compiles the script
:fname.test.vi:efname.
and generates the compiled script file
:fname.test.out:efname.
:period.
.endxmpl
.xmplsect end
.alsosee begin
.seethis load
.seethis source
.alsosee end
.endfunc
.begfunc COMPRESS
.syntx * COMpress
.begdescr
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.
.enddescr
.endfunc
.begfunc COPY
.syntx <.line_range>. COpy <.line_number>.
.begdescr
Copies the specified range of lines &range after the line &parm1.
:period.
.enddescr
.xmplsect begin
.begxmpl % copy $
Copies the entire file and places the lines after the last line
in the file.
.endxmpl
.begxmpl 1,. copy .
Copies all lines from the beginning of the file to the current line
and places the lines after the current line.
.endxmpl
.xmplsect end
.endfunc
.begfunc DATE
.syntx * DAte
.begdescr
Display the current time and date in the message window.
.enddescr
.endfunc
.begfunc DELETE
.syntx <.line_range>. Delete <.buffer>.
.begdescr
Deletes the specified line range &range.
:period.
.np
If &parm1 is not specified,
the text is deleted into the active ©buffer
:period.
.np
If &parm1 ('1'-'9', or 'a'-'z') is specified, the text is deleted into
that ©buffer
:period.
.np
The
.keyref put
command may be used to place contents of a ©buffer into the file.
.enddescr
.xmplsect begin
.begxmpl % d
Deletes all lines into the active ©buffer
:period.
.endxmpl
.begxmpl 1,10 d a
Deletes lines 1 to 10 into the named ©buffer
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -