The existance of a command line is a key feature of powerful text editors. |
The existence of a command line is a key feature of powerful text editors. |
For instance, editors in the IbmEditorFamily like ISPF/PDF, XEDIT, ICCF, THE, T, cse, X2 have an actual command line on the screen interface. Editors like Vi provide a means to execute a command in a sub-shell (via ":!command") but don't have a command line per se. Some editors, like Kate or X2, hide their command lines and provide a key sequence to make it visible. |
For instance, editors in the IbmEditorFamily like ISPF/PDF, XEDIT, ICCF, THE, T, cse have an actual command line on the screen interface. Some editors, like Kate or X2, hide their command lines and provide a key sequence to make it visible. (XEDIT can be made to hide its command line.) Editors like Vi provide a means to execute a command in a sub-shell (via ":!command") but don't have a command line per se. |
Editors with command lines, of course, also provide commands to be typed there. Many are simple: top, bottom, up, down, etc.; these are equivalent to ALT- or CTRL- key combinations used by other editors. More complicated commands like find and change are implemented in other editors with pop-up windows. When used one at a time there is little difference between command line commands and key-combination commands; the advantage for command line commands is that they can be chained together, either by separating them with a logical line-end character, or with a sort of cascading method; thus, in the X2 editor, after marking a block of lines, one may enter top^/string/^c/from/to/m* (where ^ is the logical line-end character), which does the following: #Go to the top of the file |
Editors with command lines, of course, also provide commands to be typed there. Many are simple: top, bottom, up, down, etc.; these are equivalent to ALT- or CTRL- key combinations used by other editors. More complicated commands like find and change are implemented in other editors with pop-up windows. When used one at a time there is little difference between command line commands and key-combination commands; the advantage for command line commands is that they can be chained together on the command line, either by separating them with a logical line-end character, or with a sort of cascading method; thus, in the X2 editor, after marking a block of lines, one may enter top^/string/^c/from/to/m* (where ^ is the logical line-end character), which does the following: #Go to the beginning of the file |
#Change string from to to in all marked lines from string to the bottom of the file. The XEDIT editor provides even more flexibility. The cascaded command -/firststring/c/from/to//laststring/2 does the following: |
#Change from to to in all marked lines from string to the bottom of the file. The XEDIT editor provides even more flexibility. The cascaded command locate -/firststring/ change /from/to/ /laststring/ 2¹ does the following: |
¹The locate and change commands can be abbreviated and extraneous spaces can be omitted, so -/firststring/c/from/to//laststring/2 does the same thing. (The locate command is used so often that in locate /string/ the entire word locate can be omitted.) |
|
When combined with MacroLanguage capabilities (which usually require command line commands), very complicated editing routines can be built. Such capability allows the user to customize the editor to perform a standard sequence of operations on files; for example, the XEDIT command shown above can be extended with a macro to perform the operation multiple times, e.g. until string1 is no longer found: |
When combined with MacroLanguage capabilities (which usually require command line commands), very complicated editing routines can be built. Such capability allows the user to customize the editor to perform a standard sequence of operations on files; for example, something like the XEDIT command shown above can be extended with a RexxLanguage macro to perform the operation multiple times, e.g. until fromString is no longer found. This example searches forward instead of backward: |
signal on error /* Stop when RC (return code) is non-zero. */ 'locate *-/firstString/' /* Start from the last occurance of firstString. */ |
signal on error /* Stop if RC (the return code from a command) is non-zero. */ 'top' /* Start from the top of the file. */ |
do while rc = 0 /* While the string is found, */ 'change /from/to/ /lastString/ 2' /* change fromString to toString from there to lastString, */ 'locate -/firstString/' /* then find the previous occurance of firstString. */ |
do forever /* Non-zero return code will terminate this loop. */ 'locate /firstString/' /* Find the next occurrance of firstString. */ /* change at most two occurrances of fromString to toString */ 'change /from/to/ /lastString/ 2' /* on each line from here until lastString is found. */ |
The macro can also be written to accept arbitrary strings on the command line, etc. |
The macro can also be written to accept arbitrary strings from the command line, to issue other commands between multiple loops, etc. |
|
|
|
NealStephenson? said it best [In the Beginning...]
The existance of a command line is a key feature of powerful text editors.
Command lines are used in the ViFamily, EmacsFamily, IbmEditorFamily, and others.
Also most editors that do have a commandline have an escape, usually the bang ('!') that allows one to execute system commands. Thus giving the editor a basic Shell feature.
An alternative is the ability to "filter" a buffer of text with a command. That command could be either a built-in, a macro, or a Shell command. In VI, this is the '|' pipe character's function on the CommandLine.
For instance, editors in the IbmEditorFamily like ISPF/PDF, XEDIT, ICCF, THE, T, cse, X2 have an actual command line on the screen interface. Editors like Vi provide a means to execute a command in a sub-shell (via ":!command") but don't have a command line per se. Some editors, like Kate or X2, hide their command lines and provide a key sequence to make it visible.
Editors with command lines, of course, also provide commands to be typed there. Many are simple: top, bottom, up, down, etc.; these are equivalent to ALT- or CTRL- key combinations used by other editors. More complicated commands like find and change are implemented in other editors with pop-up windows. When used one at a time there is little difference between command line commands and key-combination commands; the advantage for command line commands is that they can be chained together, either by separating them with a logical line-end character, or with a sort of cascading method; thus, in the X2 editor, after marking a block of lines, one may enter top^/string/^c/from/to/m* (where ^ is the logical line-end character), which does the following:
/* Simple EXAMPLE XEDIT */ signal on error /* Stop when RC (return code) is non-zero. */ 'locate *-/firstString/' /* Start from the last occurance of firstString. */
do while rc = 0 /* While the string is found, */ 'change /from/to/ /lastString/ 2' /* change fromString to toString from there to lastString, */ 'locate -/firstString/' /* then find the previous occurance of firstString. */ end
error: exit rc
The macro can also be written to accept arbitrary strings on the command line, etc.
By contrast, shell escapes allow one to execute non-editor commands, and perhaps insert the results into the text being edited, but this is not quite the same as modifying the text using editor commands. --JLTurriff