CommandLine

HomePage | RecentChanges | EditorIndex | TextEditorFamilies | Preferences

Difference (from prior major revision) (minor diff)

Changed: 5c5
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.

Changed: 18c18
For instance, editors in the IBMEditorFamily? like T, cse, or 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.
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.

Added: 19a20,57
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
#Locate string
#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:

#Locate the occurance of firststring preceding the current cursor position
#Change the first two occurrances of from to to on each line until laststring is found.

¹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.)

XEDIT provides a powerful all macro which allows one to filter the displayed lines to just the ones of interest, e.g. all/string1/|/string2&¬/string3/, which says,

#Show lines that contain string1 or string2, but not string3.

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:

/* Simple EXAMPLE XEDIT */
signal on error /* Stop if RC (the return code from a command) is non-zero. */
'top' /* Start from the top of the file. */

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. */
end

error:
exit rc

The macro can also be written to accept arbitrary strings from the command line, to issue other commands between multiple loops, 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




Added: 20a59,61

:This seems to me more akin to MacroLanguage capability than use of a command line. --JLTurriff


A command line is an essential feature for a text editor because quite often there are too many commands to bind to keys and there may be parameters to pass to the command that are not easy to pass by keystrokes.

NealStephenson? said it best [In the Beginning...]

The existence 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.


Perhaps we should distinguish between a command line and a shell escape?

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 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:

  1. Go to the beginning of the file
  2. Locate string
  3. 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:

  1. Locate the occurance of firststring preceding the current cursor position
  2. Change the first two occurrances of from to to on each line until laststring is found.

¹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.)

XEDIT provides a powerful all macro which allows one to filter the displayed lines to just the ones of interest, e.g. all/string1/|/string2&¬/string3/, which says,

  1. Show lines that contain string1 or string2, but not string3.

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:

 /* Simple EXAMPLE XEDIT */
   signal on error                    /* Stop if RC (the return code from a command) is non-zero. */
  'top'                               /* Start from the top of the file.                          */

   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.        */ 
   end

 error:
   exit rc

The macro can also be written to accept arbitrary strings from the command line, to issue other commands between multiple loops, 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


One of the neatest implementations of commands in a sub-shell I've seen is in the e.com TinyEditor?. e.com implemented macros by letting you bind named batch files to F-Keys (1.bat, 2.bat, etc.) Press the F-Key, and e.com would write the file being edited to a temp file, and run the named bat file in a sub-shell, passing it the temp file name. The bat file would run, performing the defined operations in the bat file on the temp file. When the bat file exited, e.com would read the changed file back in to the editing buffer. This provided an elegant means of extending e.com, by creating batch files to be text filters, performing operations that weren't built into e.com, like sorting lines in a file. Not bad for a 5K editor. --DMcCunney

This seems to me more akin to MacroLanguage capability than use of a command line. --JLTurriff


CategoryFeatures
HomePage | RecentChanges | EditorIndex | TextEditorFamilies | Preferences
Edit text of this page | View other revisions
Last edited February 23, 2021 12:25 pm (diff)
Search: