defmodule LivebookWeb.SessionLive.ShortcutsComponent do use LivebookWeb, :live_component @shortcuts %{ insert_mode: [ %{seq: ["esc"], desc: "Switch back to navigation mode"}, %{seq: ["ctrl", "↵"], desc: "Evaluate cell and stay in insert mode"} ], navigation_mode: [ %{seq: ["?"], desc: "Open this help modal"}, %{seq: ["j"], desc: "Focus next cell"}, %{seq: ["k"], desc: "Focus previous cell"}, %{seq: ["J"], desc: "Move cell down"}, %{seq: ["K"], desc: "Move cell up"}, %{seq: ["i"], desc: "Switch to insert mode"}, %{seq: ["n"], desc: "Insert Elixir cell below"}, %{seq: ["m"], desc: "Insert Markdown cell below"}, %{seq: ["N"], desc: "Insert Elixir cell above"}, %{seq: ["M"], desc: "Insert Markdown cell above"}, %{seq: ["dd"], desc: "Delete cell"}, %{seq: ["S"], desc: "Add section"}, %{seq: ["ee"], desc: "Evaluate cell"}, %{seq: ["es"], desc: "Evaluate section"}, %{seq: ["ea"], desc: "Evaluate all stale/new cells"}, %{seq: ["ej"], desc: "Evaluate cells below"}, %{seq: ["ex"], desc: "Cancel cell evaluation"}, %{seq: ["ss"], desc: "Toggle sections panel"}, %{seq: ["sn"], desc: "Show notebook settings"} ] } @impl true def mount(socket) do {:ok, assign(socket, shortcuts: @shortcuts)} end @impl true def render(assigns) do ~L"""
Livebook highly embraces keyboard navigation to improve your productivity. It operates in one of two modes similarly to the Vim text editor. In navigation mode you move around the notebook and execute commands, whereas in the insert mode you have editor focus and directly modify the given cell content.
<%= render_shortcuts_section("Navigation mode", @shortcuts.navigation_mode, @platform) %> <%= render_shortcuts_section("Insert mode", @shortcuts.insert_mode, @platform) %><%= render_seq(shortcut.seq, @platform) %> | <%= shortcut.desc %> |