Key Bindings

Haskeline provides a line-editing user interface with many interactivity commands. Currently the user may choose either Emacs or Vi style bindings by editing the ~/.haskeline file; see UserPrefs for more details.

As of version 0.5, the user may specify custom key bindings in their .haskeline file.

Commands marked with (*) are available in version 0.6.2 and later. Commands marked with (**) are available in version 0.6.2.3 and later.

Definitions:

  • ^A: Control-A
  • M-A: Option-A
  • [c]: Any Unicode printable character (Data.Char.isPrint returns True)
  • [kill]: the console's 'kill' character (usually ^U)

Other input functions

Most of the below commands are only available in getInputLine. The other input functions provide a limited amount of interactivity:

  • getInputChar returns as soon as the user types any printable character. It accepts the ^L (clear-screen) command.
  • getPassword reads an obscured line of text from the user. It accepts the Backspace and ^L (clear-screen) commands.

Commands shared by both bindings

Left/right arrow move the cursor left/right by one character
Return finish the line entry
Backspacedelete the character left of the cursor
Delete delete the character right of the cursor
[c] insert a character
Up/down arrow move backwards/forwards in the command history
Tab run tab completion
^L clear the screen
^R search backwards in history
^S search forwards in history
M-k search backwards in history for a line matching the contents to the left of the cursor (*)
M-j search forwards in history for a line matching the contents to the left of the cursor (*)
[kill] delete until the start of the line

Emacs-specific bindings

^A move to the start of the line
^E move to the end of the line
^B move left one character
^F move right one char
^_ or ^X^Uundo
^D delete the character to the right of the cursor
^D is treated as an EOF if the input line is empty and the last character pressed was not also ^D.
M-F move forwards one word
M-B move backward one word
M-W delete backwards one "big word"
M-Backspace delete backwards one word
M-D delete forwards one word
^K delete until the end of the line
^N move forwards in the history (*)
^P move backwards in the history (*)
^Y pop the most recent deletion off of the kill ring and paste it (*)
Press ^Y multiple times to rotate through all saved deletions.
M-u upper-case the next word (*)
M-l lower-case the next word (*)
M-c capitalize (first letter only) the current word (*)
^T swap the character under the cursor with the previous one (*)
^Left move backwards one word (**)
^Right move forwards one word (**)

Vi-specific bindings

The Vi bindings start in "insert mode" allowing all of the shared commands listed above. If ^D is typed when the line is empty, it is treated as an EOF; otherwise, it is ignored. Pressing ESCAPE enters the "command mode" which provides all of the shared commands except for [printable char] and Tab, allowing instead the following commands:

i enter insert mode
I enter insert mode at the start of the line
a enter insert mode after the current character
A enter insert mode at end of the line
s delete the char under the cursor and enter insert mode
S clear the line and enter insert mode
r replace one character
R replace many characters
u undo
^Rredo
[n][movement] do a movement, repeated n times
[n]d[movement] delete the characters the movement would move past
[n]c[movement] delete the characters the movement would move past, and enter insert mode
[n]x delete the character under the cursor (repeated n times)
[n]X delete the character before the cursor (repeated n times) (*)
[n]. repeat the previous command n times (*)
dd delete the whole line
cc delete the whole line and enter insert mode
D delete until the end of the line (*)
C delete the rest of the line and enter insert mode (*)
j previous line in the history (*)
k next line in the history (*)
p paste after the cursor (*)
P paste before the cursor (*)
/ search backwards through the history (*)
? search forwards through the history (*)
n continue the current history search (*)
N reverse the current history search (*)
~ toggle case (*)
^W erase previous word (*)
^Denter, when the line is not empty (*)

The movement commands are:

hleft one character
lright one character
[space]right one character
0move to the start of the line
$move to the end of the line
wright one word
bleft one word
Wright one bigword
Bleft one bigword
eend of word (*)
Eend of bigword (*)
^first non-whitespace character in the line (*)
f[c]next appearance of character [c] (*)
F[c]previous appearance of character [c] (*)
t[c]to the left of the next appearance of character [c] (*)
T[c]to the left of the previous appearance of character [c] (*)
% jump to the brace matching the one under the cursor ((), {} or []) (*)