A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Change vim mode command entry from `Shift+Escape` to `Ctrl/Cmd+Escape` (#5837)
Trevor Manz68711ff39346
diff --git a/docs/guides/editor_features/overview.md b/docs/guides/editor_features/overview.mdindex 3af4a02212..6e304a3b1e 100644--- a/docs/guides/editor_features/overview.md+++ b/docs/guides/editor_features/overview.md@@ -44,7 +44,7 @@ editing their contents.**Enter/Exit:**-- Enter command mode: `Esc` (from cell editor) or `Shift+Esc` (when vim keybindings are enabled)+- Enter command mode: `Esc` (from cell editor) or `Ctrl+Esc`/`Cmd+Esc` (when vim keybindings are enabled)- Exit command mode: `Enter` or click on a cell**Shortcuts:**@@ -63,7 +63,7 @@ When [vim keybindings](#vim-keybindings) are enabled, additional shortcuts are a### Vim keybindingsmarimo supports vim keybindings that extend to notebook editing. Within cells,-use standard vim modes. Press `Shift+Esc` from normal mode to enter [command+use standard vim modes. Press `Ctrl+Esc` (or `Cmd+Esc` on macOS) from normal mode to enter [commandmode](#command-mode) for notebook navigation.**Cell editing additions:**@@ -96,7 +96,7 @@ vimrc = relative/path/.vimrc**Command mode additions:**-When vim keybindings are enabled, press `Shift+Esc` from normal mode to enter+When vim keybindings are enabled, press `Ctrl+Esc` (or `Cmd+Esc` on macOS) from normal mode to enter[command mode](#command-mode) with additional vim-specific keybindings:- `j`/`k` - navigate cellsdiff --git a/frontend/src/components/editor/controls/keyboard-shortcuts.tsx b/frontend/src/components/editor/controls/keyboard-shortcuts.tsxindex 08baed70db..7b8b5d45f2 100644--- a/frontend/src/components/editor/controls/keyboard-shortcuts.tsx+++ b/frontend/src/components/editor/controls/keyboard-shortcuts.tsx@@ -5,6 +5,7 @@ import { EditIcon, XIcon } from "lucide-react";import { useState } from "react";import { Button } from "@/components/ui/button";import { Input } from "@/components/ui/input";+import { Kbd } from "@/components/ui/kbd";import { hotkeysAtom, useResolvedMarimoConfig } from "@/core/config/config";import type { UserConfig } from "@/core/config/config-schema";import {@@ -251,14 +252,15 @@ export const KeyboardShortcuts: React.FC = () => {const renderCommandGroup = (group: HotkeyGroup) =>renderGroup(group,- <p className="text-xs text-muted-foreground">+ <p className="text-xs text-muted-foreground flex items-center gap-1">Press{" "}{config.keymap.preset === "vim" ? (<>- <kbd>Shift</kbd>+<kbd>Esc</kbd>+ <KeyboardHotkeys shortcut={isPlatformMac() ? "Cmd" : "Ctrl"} />+ <Kbd>Esc</Kbd></>) : (- <kbd>Esc</kbd>+ <Kbd>Esc</Kbd>)}{" "}in a cell to enter command mode</p>,diff --git a/frontend/src/components/editor/navigation/__tests__/navigation.test.ts b/frontend/src/components/editor/navigation/__tests__/navigation.test.tsindex ff103a4fc5..5c8015cb79 100644--- a/frontend/src/components/editor/navigation/__tests__/navigation.test.ts+++ b/frontend/src/components/editor/navigation/__tests__/navigation.test.ts@@ -1620,12 +1620,12 @@ describe("useCellEditorNavigationProps", () => {});});- it("should focus cell when Shift+Escape is pressed in vim mode", () => {+ it("should focus cell when Ctrl+Escape is pressed in vim mode", () => {const { result } = renderWithProvider(() =>useCellEditorNavigationProps(mockCellId),);- const mockEvent = Mocks.keyboardEvent({ key: "Escape", shiftKey: true });+ const mockEvent = Mocks.keyboardEvent({ key: "Escape", ctrlKey: true });act(() => {result.current.onKeyDown?.(mockEvent);@@ -1635,7 +1635,22 @@ describe("useCellEditorNavigationProps", () => {expect(mockEvent.continuePropagation).not.toHaveBeenCalled();});- it("should not focus cell when Escape (without Shift) is pressed in vim mode", () => {+ it("should focus cell when Cmd+Escape (metaKey) is pressed in vim mode", () => {+ const { result } = renderWithProvider(() =>+ useCellEditorNavigationProps(mockCellId),+ );++ const mockEvent = Mocks.keyboardEvent({ key: "Escape", metaKey: true });++ act(() => {+ result.current.onKeyDown?.(mockEvent);+ });++ expect(focusCell).toHaveBeenCalledWith(mockCellId);+ expect(mockEvent.continuePropagation).not.toHaveBeenCalled();+ });++ it("should not focus cell when Escape (without Ctrl) is pressed in vim mode", () => {const { result } = renderWithProvider(() =>useCellEditorNavigationProps(mockCellId),);diff --git a/frontend/src/components/editor/navigation/navigation.ts b/frontend/src/components/editor/navigation/navigation.tsindex a66654a24d..c98dc72b86 100644--- a/frontend/src/components/editor/navigation/navigation.ts+++ b/frontend/src/components/editor/navigation/navigation.ts@@ -606,9 +606,9 @@ export function useCellEditorNavigationProps(cellId: CellId) {const { keyboardProps } = useKeyboard({onKeyDown: (evt) => {- // For vim mode, require Shift+Escape to exit to command mode+ // For vim mode, require Ctrl+Escape (or Cmd+Escape on Mac) to exit to command modeif (keymapPreset === "vim") {- if (evt.key === "Escape" && evt.shiftKey) {+ if (evt.key === "Escape" && (evt.ctrlKey || evt.metaKey)) {setTemporarilyShownCode(false);focusCell(cellId);}