Command-Line Editing - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Reference : Shortcuts : Shortcut Keys : Command-Line Editing

Command-line Editing

 

Description

Quick Summary of Editing Commands

Editing Commands for EMACS Mode

Editing Commands for Vi Mode

Editing Commands Common to vi and EMACS Modes

Command Completion

Long Lines

Command History Manipulation

Interface Settings

Description

• 

The TTY version of Maple maintains a 5000-line command history. You can recall previously typed lines, edit them, and re-execute them. Two different sets of editing commands can be used: EMACS mode and VI mode.

Quick Summary of Editing Commands

EMACS

VI

Function

Mode

Mode

Description

 

 

 

Ctrl-P

k

Recall Previous line

Ctrl-N

j

Recall Next line

Ctrl-B

h

Move cursor Backward

Ctrl-F

l

Move cursor Forward

Ctrl-A

0

Move cursor to beginning of line

Ctrl-E

$

Move cursor to End of line

Ctrl-]

%

Move cursor to matching parenthesis,

 

 

bracket, or brace

Ctrl-W

w

Move cursor to next Word

Ctrl-Y

b

Move cursor to previous word

Ctrl-D

x

Delete character at cursor

Backspace

X

Delete character to left of cursor and

 

 

move left

Ctrl-K

C

Delete to end of line

Ctrl-G

S

Delete entire line

Ctrl-V

 

Switch between insert and replace modes

Ctrl-U

U

Undo changes made to line

Ctrl-R

?

Search for line containing what has

 

 

been typed

Ctrl-L

 

Redraw line

Tab,

 

 

Ctrl-Space,

 

 

Ctrl-2, or

 

 

Ctrl-@

 

Complete command

Ctrl-T

 

Show command completion matches

Escape

 

Enter VI command mode

 

i

Insert text before character

 

a

Append text after character

 

I

Insert text at beginning of line

 

A

Append text at end of line

 

R

Enter Replace mode

 

r

Replace one character and return to VI

 

 

mode

 

s

Delete character and insert text

 

D

Delete to end of line and remain in VI

 

 

mode

 

f

Search forward for character

 

F

Search backward for character

 

;

Repeat last f or F search

 

,

Repeat last f or F search in opposite

 

 

direction

Editing Commands for EMACS Mode

• 

The EMACS mode commands are based on a subset of the single key EMACS commands. In EMACS mode, any text you type is inserted into (or replaces if Ctrl-V has been pressed) the command line. The EMACS mode editing commands are always active (even in VI mode). The following commands are available:

Ctrl-P

Retrieve the previous line from the history and put the cursor at the beginning of that line.

Ctrl-N

Retrieve the next line from the history and put the cursor at the beginning of that line.

Ctrl-B

Move the cursor left one character, unless it is already at the left margin.

Ctrl-F

Move the cursor right one character, unless it is already to the right of the last non-blank character on the line.

Ctrl-A

Move the cursor to the beginning of the line.

Ctrl-E

Move the cursor to the end of the line.

Ctrl-]

Move the cursor to the matching (, ), [, ], {, or }.

Ctrl-W

Move the cursor to the beginning of the next word, where a word is a sequence of one or more alphanumeric characters (including the "_" character), or a sequence of one or more non-alphanumeric characters.

Ctrl-Y

Move the cursor to the beginning of the current word, or to the beginning of the previous word if it is already at the beginning of a word.

Ctrl-D

Erase the character at the cursor position, moving all characters to the right of the cursor left by one.

Backspace,

 

Delete, or

 

Ctrl-H

Move the cursor left and then erase the character at the new cursor position, moving all characters to the right of the cursor left by one.

Ctrl-K

Erase to the end of the line.

Ctrl-G or

 

Ctrl-X

Erase the entire line.

Ctrl-V

Toggle between insert mode and replace mode. In insert mode (the default when Maple starts), typed characters are inserted at the cursor position, and any characters to the right of the cursor are shifted to make room. In replace mode, typed characters replace those already there.

Tab

 

Ctrl-I

If insert mode is active, spaces are inserted until the cursor reaches a tabstop. Tabstops are equally spaced, the spacing being determined by interface(indentamount). If replace mode is active, the cursor moves, but no characters are changed.

Ctrl-U

Undo the changes made to the line, restoring it to its initial state. If the line is new, this key has the effect of erasing the line (since the line was initially blank).

Ctrl-R

Using the text typed on the line as a search string, search backwards through the history looking for a line containing that string.

• 

Note that these commands (except Ctrl-U, Ctrl-V, Ctrl-W, Ctrl-X, Ctrl-Y, and Ctrl-]) perform a similar function in the EMACS text editor, except that the search facility in Maple requires the search string to be typed before you press Ctrl-R instead of after.

Editing Commands for Vi Mode

• 

The vi mode commands are a subset of the single key commands understood by the vi text editor. When using the vi mode commands, the Maple session behaves as a vi session that is in input mode by default. To enter vi mode, press the Escape key (Ctrl-[ if your terminal does not have an Escape key). Note that this is the same key that you use to enter command mode in the real vi text editor. When you are in vi mode, the following keys can be used:

k

Retrieve the previous line from the history and put the cursor at the beginning of that line.

j

Retrieve the next line from the history and put the cursor at the beginning of that line.

h

Move the cursor left one character, unless it is already at the left margin.

l

 

Space

Move the cursor right one character, unless it is already to the right of the last non-blank character on the line.

0

Move the cursor to the beginning of the line.

$

Move the cursor to the end of the line.

%

Move the cursor to the matching (, ), [, ], {, or }.

w

Move the cursor to the beginning of the next word, where a word is a sequence of one or more alphanumeric characters (including the "_" character), or a sequence of one or more non-alphanumeric characters.

b

Move the cursor to the beginning of the current word, or to the beginning of the previous word if it is already at the beginning of a word.

x

Erase the character at the cursor position, moving all characters to the right of the cursor left by one.

X

Move the cursor left and then erase the character at the new cursor position, moving all characters to the right of the cursor left by one.

D

Erase to the end of the line and remain in VI mode.

i

Return to text insertion mode.

I

Move to the beginning of the line and return to text insertion mode.

a

Move right one character and return to text insertion mode.

A

Move to the right of the last non-blank character on the line and return to text insertion mode.

C

Erase to the end of the line and return to text insertion mode.

s

Erase the character at the cursor position and return to text insertion mode.

S

Erase the entire line and return to text insertion mode.

r

Erase the character at the cursor position and replace it with the next character typed.

R

Enter text replace mode at the current position. Subsequently typed characters replace those already there.

U

Undo the changes made to the line, restoring it to its initial state. If the line is new, this key has the effect of erasing the line (since the line was initially blank).

?

Using the text typed on the line as a search string, search backwards through the history looking for a line containing that string.

f,F

Search for the next (f) or previous (F) occurrence of the next character typed and move the cursor there.

;

Continue searching in the same direction for the next occurrence of the character searched for in the last f or F command.

,

Continue searching in the opposite direction for the next occurrence of the character searched for in the last f or F command.

• 

Several vi mode commands (b, f, F, h, j, k, l, s, w, X, x, ";", and ",") can be preceded by a numerical argument between 1 and 999 to indicate the number of times the command is to be executed. When you type the argument, you do not see anything appear on the screen. If you type more than two digits, the argument modulo 100 is used.

• 

Note that these commands perform a similar function in the vi text editor, except that the search facility in Maple requires the search string be typed before you press ? instead of after.

Editing Commands Common to vi and EMACS Modes

• 

If your terminal has arrow keys that generate VT100 compatible control sequences, you can use the arrow keys as well. These are active in both vi and EMACS modes.

• 

If you suspect that the screen display does not match the contents of Maple's input buffer, press Ctrl-L to move the cursor to a blank line and redraw the input. The cursor remains in the same position relative to the input.

Command Completion

• 

Pressing Tab or Ctrl-Space (you may have to use Ctrl-@ or Ctrl-2 on some platforms) after typing a partial command causes Maple to try to complete the command. Maple compares all names known to the system. If the partial name is recognized as a module member, the exports of the respective module are used for the command completion.

• 

If more than one command matches, Maple completes the command to the longest prefix common to all matches.

• 

To see a list of all matches, press Ctrl-T. Maple displays (starting on a new line) a list of all matches, and then redraws the input line. You can then type more characters and press Tab or Ctrl-Space again to further complete the command.

Long Lines

• 

The command-line editor accepts input lines up to 1024 characters in length. Once there are 1024 characters on a line, Maple beeps. Additional characters are ignored.

• 

When the cursor moves off the right side of the screen, the input line is split and redrawn, showing the last screenwidth/2 characters of the line containing the cursor. Thus, the cursor appears approximately in the middle of the screen. When the cursor moves off the left side of the screen, the entire input up to screenwidth/2 characters past the cursor position is redrawn. The cursor is placed approximately in the middle of the screen. For this horizontal scrolling feature to work properly, it is imperative that interface(screenwidth) is set to no more than the actual width (in characters) of your screen.

Command History Manipulation

• 

In addition to traversing the command history using the keys described here, there is a set of history manipulation meta-commands that can be used to examine, edit, replay, save, and restore the history. These are described on the Command-line Edit History page.

Interface Settings

• 

The Maple interface() function is used to set various parameters of the user interface. Some of these settings affect the command line editor:

prompt

The command-line editor looks at the prompt setting to determine how much space there is on the line to the right of the prompt.  This is needed to determine when to wrap the line.

screenwidth

The screenwidth is also needed to determine the line lengths at which to scroll. The command-line editor does not work correctly if the screenwidth setting is larger than the actual width of the screen you are using.

indentamount

Maple normally uses this setting to indent output when pretty printing Maple procedures. The command-line editor uses this setting to determine how far to move when you press the Tab key.

errorcursor

This setting controls what happens when a syntax error occurs. If set to true, the line containing the error is placed in the editing buffer, and the cursor is placed on the location at which the error was detected. If set to false, the line containing the error is printed, with a "^" underneath the location of the error, and the cursor on a new blank line.

fakecursor

Due to limitations of the command console in Microsoft Windows, the cursor is often not visible while actively typing or using the cursor movement keys. Setting fakecursor to true will cause the command editor to simulate a cursor by rendering the character currently at the cursor location in reverse video.

historysize

This specifies the number of input lines retained in the command-line history. It is a 5000 by default, and can be set to any number between 0 and 1000000. If set to 0, then no command history is retained.

historyfile

Command history is retained between Maple sessions by storing it in a history file. By default, this is ".maple_history" in the user's home directory. This can be changed to another file if desired, or disabled by setting it to the name none or the empty string. The default file name can be restored by setting historyfile to the name default.

historytimestamp

This is set to false by default, but if set to true in the user's Maple initialization file, a timestamp will be inserted as a comment in the command history when a new session is started.

ansiedit

If interface(ansi) is true, setting ansiedit to true will enable dynamic syntax highlighting during input on the command line. Added in Maple 2018.1.