utop key bindings / key shortcuts

Posted on In QA

utop is an improved toplevel for OCaml supporting line edition, history, real-time and context sensitive completion, colors and etc.

utop is convenient to use. However, the key bindings are a little bit different from the ones with GNU readline. What are all the key bindings?

The #utop_bindings command will print all the key bindings. Here is the output from the utop of my installation (here is a plain text version):

#utop_bindings;;
enter       : accept                        -> accept the current input.
escape      : cancel-search                 -> cancel search mode.
tab         : complete                      -> complete current input.
up          : history-prev                  -> go to the previous entry of the history.
down        : history-next                  -> go to the next entry of the history.
left        : prev-char                     -> move the cursor to the previous character.
right       : next-char                     -> move the cursor to the next character.
home        : goto-bot                      -> move the cursor to the beginning of the text.
end         : goto-eot                      -> move the cursor to the end of the text.
insert      : switch-erase-mode             -> switch the current erasing mode.
delete      : delete-next-char              -> delete the character after the cursor.
backspace   : delete-prev-char              -> delete the character before the cursor.
M-enter     : newline                       -> insert a newline character.
M-tab       : complete-bar                  -> complete current input using the completion bar.
M-down      : complete-bar                  -> complete current input using the completion bar.
M-left      : complete-bar-prev             -> go to the previous possible completion in the completion bar.
M-right     : complete-bar-next             -> go to the next possible completion in the completion bar.
M-home      : complete-bar-first            -> go to the beginning of the completion bar.
M-end       : complete-bar-last             -> go to the end of the completion bar.
M-delete    : kill-prev-word                -> cut the word behind the cursor.
M-backspace : kill-prev-word                -> cut the word behind the cursor.
M-b         : prev-word                     -> move the cursor to the beginning of the previous word.
M-c         : capitalize-word               -> capitalize the first word after the cursor.
M-d         : kill-next-word                -> cut up until the next non-word character.
M-f         : next-word                     -> move the cursor to the end of the next word.
M-l         : lowercase-word                -> convert the first word after the cursor to lowercase.
M-n         : history-next                  -> go to the next entry of the history.
M-p         : history-prev                  -> go to the previous entry of the history.
M-u         : uppercase-word                -> convert the first word after the cursor to uppercase.
M-w         : copy                          -> copy the current region to the clipboard.
C-left      : prev-word                     -> move the cursor to the beginning of the previous word.
C-right     : next-word                     -> move the cursor to the end of the next word.
C-delete    : kill-next-word                -> cut up until the next non-word character.
C-space     : set-mark                      -> set the mark to the current position.
C-_         : undo                          -> revert the last action.
C-a         : goto-bol                      -> move the cursor to the beginning of the current line.
C-b         : prev-char                     -> move the cursor to the previous character.
C-c         : break                         -> cancel edition.
C-d         : interrupt-or-delete-next-char -> interrupt if at the beginning of an empty line, or delete the next character.
C-e         : goto-eol                      -> move the cursor to the end of the current line.
C-f         : next-char                     -> move the cursor to the next character.
C-g         : cancel-macro                  -> cancel the current macro.
C-h         : delete-prev-char              -> delete the character before the cursor.
C-k         : kill-next-line                -> cut everything until the end of the current line.
C-l         : clear-screen                  -> clear the screen.
C-m         : accept                        -> accept the current input.
C-n         : next-char                     -> move the cursor to the next character.
C-p         : prev-char                     -> move the cursor to the previous character.
C-r         : prev-search                   -> search backward in the history.
C-u         : kill-prev-line                -> cut everything until the beginning of the current line.
C-w         : kill                          -> cut the current region to the clipboard.
C-x (       : start-macro                   -> start a new macro.
C-x )       : stop-macro                    -> end the current macro.
C-x e       : play-macro                    -> play the last recorded macro.
C-x C-k tab : insert-macro-counter          -> insert the current value of the macro counter.
C-x C-k C-a : add-macro-counter             -> adds a value to the macro counter.
C-x C-k C-c : set-macro-counter             -> sets the value of the macro counter.
C-y         : yank                          -> paste the contents of the clipboard at current position.
C-z         : suspend                       -> suspend edition.

Leave a Reply

Your email address will not be published. Required fields are marked *