Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uji.keymap

A binding belongs to one of five modes.

ModeWhere it applies
normalThe input line.
suggestThe command list that opens when you type /.
selectPickers and lists.
promptText prompts.
confirmThe approval question.

A key is a single character such as "q", or a chord in angle brackets. <C-x> is Ctrl, <A-x> or <M-x> is Alt, <S-x> is Shift, and they combine, as in <C-A-x>. The named keys are CR, Esc, BS, Del, Tab, S-Tab, Left, Right, Up, Down, Home, End, PageUp, PageDown, Insert, Space, lt for <, gt for >, and F1 to F12.

uji.keymap.add(mode, key, binding)

Binds a key in one mode, replacing what the key did there.

ArgumentTypeMeaning
modestringOne of the five modes.
keystringA key or chord.
bindingstring, table or functionAn action name from the list below, { command = "name" } to run a slash command, or a function.

Raises an error for an unknown mode, a key uji cannot parse, or a binding of another type.

uji.keymap.add("normal", "<C-p>", { command = "models" })
uji.keymap.add("normal", "<C-l>", "clear_input")
uji.keymap.add("normal", "<A-i>", function()
  uji.session.interrupt()
end)

uji.keymap.remove(mode, key)

Unbinds a key in one mode, including a default binding.

uji.keymap.remove("normal", "<C-t>")

uji.keymap.reset()

Restores the default bindings.

uji.keymap.reset()

uji.keymap.list()

Returns one row per binding, with mode, key, and one of action, command or unbound = true.

for _, row in ipairs(uji.keymap.list()) do
  if row.command then
    uji.notify(row.key .. " runs /" .. row.command)
  end
end

Default bindings

KeysActionModes
Ctrl+Cquitall
Ctrl+A, Ctrl+Ecursor_start, cursor_endnormal, suggest, prompt, select
Ctrl+B, Ctrl+Fcursor_left, cursor_rightnormal, suggest, prompt, select
Alt+B, Alt+Fword_left, word_rightnormal, suggest, prompt, select
Ctrl+Hbackspacenormal, suggest, prompt, select
Ctrl+Ddelete_forwardnormal, suggest, prompt, select
Ctrl+W, Alt+Backspacedelete_word_backnormal, suggest, prompt, select
Alt+Ddelete_word_forwardnormal, suggest, prompt, select
Ctrl+U, Ctrl+Kdelete_to_start, delete_to_endnormal, suggest, prompt, select
Ctrl+Yyanknormal, suggest, prompt, select
Ctrl+Ttransposenormal, suggest, prompt, select
Ctrl+P, Ctrl+Nhistory_prev, history_nextnormal
Ctrl+P, Ctrl+Nmodal_up, modal_downselect, suggest, confirm
Ctrl+Gmodal_cancelselect, suggest, confirm
Shift+Enter, Alt+Enter, Ctrl+Jinsert_newlinenormal
Ctrl+Vpaste_imagenormal

Enter, Esc, Tab, the arrow keys, and y and n in the approval question work without a binding. A binding on one of these keys overrides it.

Actions

nothing, quit, interrupt, toggle_thinking, submit, clear_input, backspace, delete_forward, delete_word_back, delete_word_forward, delete_to_start, delete_to_end, yank, paste_image, transpose, insert_newline, cursor_left, cursor_right, cursor_start, cursor_end, word_left, word_right, scroll_up, scroll_down, page_up, page_down, scroll_top, scroll_bottom, history_prev, history_next, modal_up, modal_down, modal_accept, modal_cancel, suggest_complete, confirm_allow, confirm_deny, confirm_toggle.

uji.action.add adds your own.