Key Bindings

Editing Modes

The key-bindings used when editing a cell or in the console are determined by the edit_mode configuration variable. This can be set to micro, emacs or vim to use key-bindings in the style of the respective text editor.

Custom Key Bindings

Key bindings can be customized by setting the key_bindings configuration parameter.

This parameter takes the form of a mapping, where they keys are references to modes or components to which a set of key-bindings apply, and the values are mapping of command names to lists of keys.

Key bindings set in the configuration will entirely over-ride the default binding, so if you want to add an additional binding for a command while retaining the default, you will need to include the default binding in the configuration.

Below is an example Configuration File showing how the key-bindings can be set:

{
  "notebook": {
    "autoformat": false,
    "expand": true,
    "key_bindings": {
      "euporie.notebook.app.NotebookApp": {
        "quit": ["c-q", "c-p"],
        "new-notebook": []
      }
    },
  }
}

This example sets two key-bindings in the Notebook app for the quit command: Ctrl+Q and Ctrl+P. It also unsets any key-bindings for the new-notebook command.

Custom key-binding configuration can also be passed on the command line in the form of a JSON string:

$ euporie-notebook --key-bindings='{"euporie.notebook.app.NotebookApp": {"new-notebook": [],"quit": ["c-q", "c-p"]}}'

Valid component names include:

  • euporie.core.app.BaseApp

  • euporie.core.widgets.pager.Pager

  • euporie.core.widgets.inputs.KernelInput

  • euporie.core.key_binding.bindings.micro.EditMod

  • euporie.notebook.app.NotebookApp

  • euporie.notebook.tabs.notebook.Notebook

  • euporie.console.app.ConsoleApp

  • euporie.console.tabs.console.Console

  • euporie.preview.app.PreviewApp

Most command names are listed in Default Key Bindings Reference.

Running Cells

Cells can be run using Ctrl+Enter, or Shift+Enter to run and select the next cell, as is the case in JupyterLab.

However, most terminals do not distinguish between Enter, Ctrl+Enter & Shift+Enter by default, meaning that you have to use alternative key-bindings in euporie to run cells.

Fortunately it is possible to configure many terminals such that these key-bindings can be used, as outlined below.

Note

There are two commonly used formats of escape sequences which can be used to distinguish these key-bindings: FK-27 and CSI-u. The instructions below implement the CSI-u style, but euporie will recognise either.

WezTerm

Update your $HOME/.config/wezterm/wezterm.lua file to include the following:

local wezterm = require 'wezterm';

return {
  -- ...

  keys = {
    {key="Enter", mods="CTRL", action=wezterm.action{SendString="\x1b[13;5u"}},
    {key="Enter", mods="SHIFT", action=wezterm.action{SendString="\x1b[13;2u"}},
  },
}

Kitty

Add the following to your $HOME/.config/kitty/kitty.conf file:

map ctrl+enter send_text normal,application \x1b[13;5u
map shift+enter send_text normal,application \x1b[13;2u

XTerm

You can add the following lines to your $HOME/.Xresources file, which enables CSI-u escape sequences.

*vt100.modifyOtherKeys: 1
*vt100.formatOtherKeys: 1

Windows Terminal

You can add the key-bindings to your settings.json file:

{
  // ...

  "keybindings":
  [
    { "command": { "action": "sendInput", "input": "\u001b[13;5u" }, "keys": "ctrl+enter" },
    { "command": { "action": "sendInput", "input": "\u001b[13;2u" }, "keys": "shift+enter" }
  ]
}

Alacritty

You can define the key-binding in your $HOME/.config/alacritty/alacritty.yml file as follows:

key_bindings:
  - { key: Return, mods: Control, chars: "\x1b[13;5u" }
  - { key: Return, mods: Shift,   chars: "\x1b[13;2u" }

Konsole

In the menu, navigate to Settings ‣ Edit Current Profile, then select Keyboard ‣ Edit.

Change the existing entry for Return+Shift to Return+Shift+Ctrl (or whatever you prefer), then add the following entries:

Key combination

Output

Return+Ctrl

E[13;5u

Return+Shift

E[13;2u

Default Key Bindings Reference

The following lists outline the default key-bindings used in euporie:

All euporie apps

Base class for interface tabs

Notebook app

Interactive notebooks

Conole app

Interactive console

Preview app

Micro style editor key-bindings

Interactive help pager

Kernel input text areas

Rich output displays

Web view displays


Default Key-binding configuration

The following lists all of the default key-bindings used in euporie in the format required for custom key-bindings in the configuration file.

{
  "euporie.core.app.BaseApp": {
    "quit": "c-q",
    "close-tab": "c-w",
    "next-tab": "c-pagedown",
    "previous-tab": "c-pageup",
    "focus-next": "s-tab",
    "focus-previous": "tab",
    "clear-screen": "c-l",
    "next-completion": "c-i",
    "previous-completion": "s-tab",
    "cancel-completion": "escape",
    "accept-completion": "enter",
    "open-file": "c-o",
    "save-as": "A-s",
    "show-command-palette": "c-@",
    "find": [
      "c-f",
      "f3",
      "f7"
    ],
    "find-next": "c-g",
    "find-previous": "c-p"
  },
  "euporie.core.tabs.base.Tab": {
    "save-file": "c-s",
    "refresh-tab": "f5"
  },
  "euporie.notebook.app.NotebookApp": {
    "toggle-side-bar-pane": "c-b",
    "new-notebook": "c-n",
    "toggle-show-top-bar": "A-m"
  },
  "euporie.notebook.tabs.notebook.Notebook": {
    "enter-cell-edit-mode": "enter",
    "exit-edit-mode": "escape",
    "run-selected-cells": [
      "c-enter",
      "c-e"
    ],
    "run-and-select-next": [
      "s-enter",
      "c-r"
    ],
    "run-cell-and-insert-below": "A-enter",
    "add-cell-above": "a",
    "add-cell-below": "b",
    "delete-cells": [
      "d",
      "d"
    ],
    "undelete-cells": "z",
    "cut-cells": "x",
    "copy-cells": "c",
    "copy-outputs": "A-c",
    "paste-cells": "v",
    "interrupt-kernel": [
      "i",
      "i"
    ],
    "restart-kernel": [
      "0",
      "0"
    ],
    "scroll-up": [
      "[",
      "<scroll-up>"
    ],
    "scroll-down": [
      "]",
      "<scroll-down>"
    ],
    "scroll-up-5-lines": "{",
    "scroll-down-5-lines": "}",
    "select-first-cell": [
      "home",
      "c-up"
    ],
    "select-5th-previous-cell": "pageup",
    "select-previous-cell": [
      "up",
      "k"
    ],
    "select-next-cell": [
      "down",
      "j"
    ],
    "select-5th-next-cell": "pagedown",
    "select-last-cell": [
      "end",
      "c-down"
    ],
    "select-all-cells": "c-a",
    "extend-cell-selection-to-top": "s-home",
    "extend-cell-selection-up": [
      "s-up",
      "K"
    ],
    "extend-cell-selection-down": [
      "s-down",
      "J"
    ],
    "extend-cell-selection-to-bottom": "s-end",
    "move-cells-up": "A-up",
    "move-cells-down": "A-down",
    "cells-to-markdown": "m",
    "cells-to-code": "y",
    "cells-to-raw": "r",
    "reformat-cells": "f",
    "reformat-notebook": "F",
    "edit-in-external-editor": "e",
    "merge-cells": "M",
    "split-cell": "c-\\",
    "edit-previous-cell": "up",
    "edit-next-cell": "down",
    "edit-previous-cell-vi": "k",
    "edit-next-cell-vi": "j",
    "scroll-output-left": "left",
    "scroll-output-right": "right",
    "toggle-expand": "w",
    "toggle-wrap-cell-outputs": "W",
    "notebook-toggle-line-numbers": "l"
  },
  "euporie.console.app.ConsoleApp": {
    "clear-input": "c-c",
    "run-input": [
      "c-enter",
      "c-e"
    ],
    "clear-screen": "c-l",
    "end-of-file": "c-d"
  },
  "euporie.console.tabs.console.Console": {
    "cc-interrupt-kernel": "c-c"
  },
  "euporie.preview.app.PreviewApp": {
    "quit": [
      "c-c",
      "c-q"
    ]
  },
  "euporie.core.key_binding.bindings.micro.EditMode": {
    "move-cursor-right": "right",
    "move-cursor-left": "left",
    "newline": "enter",
    "accept-line": "enter",
    "backspace": [
      "backspace",
      "c-h"
    ],
    "backward-kill-word": [
      "c-backspace",
      "A-backspace",
      "c-A-h",
      [
        "escape",
        "c-h"
      ]
    ],
    "start-selection": [
      "s-up",
      "s-down",
      "s-right",
      "s-left",
      "A-s-left",
      "A-s-right",
      "c-s-left",
      "c-s-right",
      "s-home",
      "s-end",
      "c-s-home",
      "c-s-end"
    ],
    "extend-selection": [
      "s-up",
      "s-down",
      "s-right",
      "s-left",
      "A-s-left",
      "A-s-right",
      "c-s-left",
      "c-s-right",
      "s-home",
      "s-end",
      "c-s-home",
      "c-s-end"
    ],
    "cancel-selection": [
      "up",
      "down",
      "right",
      "left",
      "A-left",
      "A-right",
      "c-left",
      "c-right",
      "home",
      "end",
      "c-home",
      "c-end"
    ],
    "replace-selection": "<any>",
    "delete-selection": [
      "delete",
      "backspace",
      "c-h"
    ],
    "backward-word": [
      "c-left",
      "A-b"
    ],
    "forward-word": [
      "c-right",
      "A-f"
    ],
    "move-lines-up": "A-up",
    "move-lines-down": "A-down",
    "go-to-start-of-line": [
      "home",
      "A-left",
      "A-a"
    ],
    "go-to-end-of-line": [
      "end",
      "A-right",
      "A-e"
    ],
    "beginning-of-buffer": [
      "c-up",
      "c-home"
    ],
    "end-of-buffer": [
      "c-down",
      "c-end"
    ],
    "go-to-start-of-paragraph": "A-{",
    "go-to-end-of-paragraph": "A-}",
    "indent-lines": "tab",
    "unindent-line": "backspace",
    "unindent-lines": "s-tab",
    "undo": "c-z",
    "redo": "c-y",
    "copy-selection": "c-c",
    "cut-selection": [
      "c-x",
      "s-delete"
    ],
    "cut-line": "c-k",
    "duplicate-line": "c-d",
    "duplicate-selection": "c-d",
    "paste-clipboard": "c-v",
    "select-all": "c-a",
    "scroll-page-up": "pageup",
    "scroll-page-down": "pagedown",
    "delete": "delete",
    "toggle-case": "f4",
    "toggle-overwrite-mode": "insert",
    "start-macro": "c-u",
    "end-macro": "c-u",
    "run-macro": "c-j",
    "accept-suggestion": [
      "right",
      "c-f"
    ],
    "fill-sugestion": "A-f",
    "toggle-comment": "c-_",
    "go-to-matching-bracket": [
      "A-(",
      "A-)"
    ],
    "wrap-selection-\"\"": "\"",
    "wrap-selection-''": "'",
    "wrap-selection-()": [
      "(",
      ")"
    ],
    "wrap-selection-{}": [
      "{",
      "}"
    ],
    "wrap-selection-[]": [
      "[",
      "]"
    ],
    "wrap-selection-``": "`",
    "wrap-selection-**": "*",
    "wrap-selection-__": "_"
  },
  "euporie.core.widgets.pager.Pager": {
    "close-pager": [
      "A-q"
    ]
  },
  "euporie.core.widgets.inputs.KernelInput": {
    "show-contextual-help": "s-tab",
    "history-prev": "c-A-up",
    "history-next": "c-A-down"
  },
  "euporie.core.widgets.display.Display": {
    "scroll-display-left": "left",
    "scroll-display-right": "right",
    "scroll-display-up": [
      "up",
      "k"
    ],
    "scroll-display-down": [
      "down",
      "j"
    ],
    "page-up-display": "pageup",
    "page-down-display": "pagedown",
    "go-to-start-of-display": "home",
    "go-to-end-of-display": "end"
  },
  "euporie.web.widgets.webview.WebViewControl": {
    "scroll-webview-left": "left",
    "scroll-webview-right": "right",
    "scroll-webview-up": [
      "up",
      "k"
    ],
    "scroll-webview-down": [
      "down",
      "j"
    ],
    "page-up-webview": "pageup",
    "page-down-webview": "pagedown",
    "go-to-start-of-webview": "home",
    "go-to-end-of-webview": "end",
    "webview-nav-prev": "A-left",
    "webview-nav-next": "A-right"
  }
}