From 8f3b92ff115b4c4c0eb90b3c1d293b996de88f7f Mon Sep 17 00:00:00 2001 From: Gregoire Geis Date: Thu, 11 Sep 2025 18:09:26 +0900 Subject: [PATCH] commands: escape insert mode with ctrl-[ Fixes #334. --- extensions/helix/package.json | 6 ++++++ package.json | 6 ++++++ src/api/data/commands.yaml | 11 ++++++----- src/commands/README.md | 12 ++++++------ src/commands/layouts/azerty.fr.md | 12 ++++++------ src/commands/layouts/qwerty.md | 12 ++++++------ src/commands/modes.ts | 10 +++++----- 7 files changed, 41 insertions(+), 28 deletions(-) diff --git a/extensions/helix/package.json b/extensions/helix/package.json index 306e1b48..488c2eea 100644 --- a/extensions/helix/package.json +++ b/extensions/helix/package.json @@ -2012,6 +2012,12 @@ "title": "Set mode to Normal", "command": "dance.modes.set.normal" }, + { + "key": "Ctrl+[", + "when": "editorTextFocus && dance.mode == 'helix/insert'", + "title": "Set mode to Normal", + "command": "dance.modes.set.normal" + }, { "key": "V", "when": "editorTextFocus && dance.mode == 'helix/normal'", diff --git a/package.json b/package.json index 7fea66b3..9e353f27 100644 --- a/package.json +++ b/package.json @@ -2473,6 +2473,12 @@ "title": "Set mode to Normal", "command": "dance.modes.set.normal" }, + { + "key": "Ctrl+[", + "when": "editorTextFocus && dance.mode == 'insert'", + "title": "Set mode to Normal", + "command": "dance.modes.set.normal" + }, { "key": "Ctrl+V", "when": "editorTextFocus && dance.mode == 'normal'", diff --git a/src/api/data/commands.yaml b/src/api/data/commands.yaml index bb88ed24..55d3dc1e 100644 --- a/src/api/data/commands.yaml +++ b/src/api/data/commands.yaml @@ -683,11 +683,11 @@ modes.set: #### Variants - | Title | Identifier | Keybinding | Command | - | ------------------ | ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | - | Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | - | Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | - | Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | + | Title | Identifier | Keybinding | Command | + | ------------------ | ------------ | --------------------------------------------------------------------------------- | ----------------------------------------------------------- | + | Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select), `c-[` (core: insert) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | + | Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | + | Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | Other variants are provided to switch to insert mode: @@ -713,6 +713,7 @@ modes.set.normal: qwerty: |- `escape` (core: insert; helix: select) `v` (helix: select) + `c-[` (core: insert) commands: |- [".modes.set", { mode: "normal" }], ["hideSuggestWidget"] diff --git a/src/commands/README.md b/src/commands/README.md index 2bce2fd5..248ee687 100644 --- a/src/commands/README.md +++ b/src/commands/README.md @@ -84,7 +84,7 @@ selections are empty modes.insert.lineEndInsert at line endShift+A (editorTextFocus && dance.mode == 'normal')Shift+A (editorTextFocus && dance.mode == 'select') modes.insert.lineStartInsert at line startShift+I (editorTextFocus && dance.mode == 'normal')Shift+I (editorTextFocus && dance.mode == 'select') modes.set.insertSet mode to Insert -modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select') +modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select')Ctrl+[ (editorTextFocus && dance.mode == 'insert') modes.set.selectSet mode to SelectV (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.insertTemporary Insert modeCtrl+V (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.normalTemporary Normal modeCtrl+V (editorTextFocus && dance.mode == 'insert') @@ -925,11 +925,11 @@ Set Dance mode. #### Variants -| Title | Identifier | Keybinding | Command | -| ------------------ | ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | -| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | -| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | -| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | +| Title | Identifier | Keybinding | Command | +| ------------------ | ------------ | --------------------------------------------------------------------------------- | ----------------------------------------------------------- | +| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select), `c-[` (core: insert) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | +| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | +| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | Other variants are provided to switch to insert mode: diff --git a/src/commands/layouts/azerty.fr.md b/src/commands/layouts/azerty.fr.md index cb4a9cb8..ed6179b9 100644 --- a/src/commands/layouts/azerty.fr.md +++ b/src/commands/layouts/azerty.fr.md @@ -69,7 +69,7 @@ selections are empty modes.insert.lineEndInsert at line endShift+A (editorTextFocus && dance.mode == 'normal')Shift+A (editorTextFocus && dance.mode == 'select') modes.insert.lineStartInsert at line startShift+I (editorTextFocus && dance.mode == 'normal')Shift+I (editorTextFocus && dance.mode == 'select') modes.set.insertSet mode to Insert -modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select') +modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select')Ctrl+[ (editorTextFocus && dance.mode == 'insert') modes.set.selectSet mode to SelectV (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.insertTemporary Insert modeCtrl+V (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.normalTemporary Normal modeCtrl+V (editorTextFocus && dance.mode == 'insert') @@ -910,11 +910,11 @@ Set Dance mode. #### Variants -| Title | Identifier | Keybinding | Command | -| ------------------ | ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | -| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | -| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | -| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | +| Title | Identifier | Keybinding | Command | +| ------------------ | ------------ | --------------------------------------------------------------------------------- | ----------------------------------------------------------- | +| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select), `c-[` (core: insert) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | +| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | +| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | Other variants are provided to switch to insert mode: diff --git a/src/commands/layouts/qwerty.md b/src/commands/layouts/qwerty.md index 9489a35b..c08aa1b2 100644 --- a/src/commands/layouts/qwerty.md +++ b/src/commands/layouts/qwerty.md @@ -69,7 +69,7 @@ selections are empty modes.insert.lineEndInsert at line endShift+A (editorTextFocus && dance.mode == 'normal')Shift+A (editorTextFocus && dance.mode == 'select') modes.insert.lineStartInsert at line startShift+I (editorTextFocus && dance.mode == 'normal')Shift+I (editorTextFocus && dance.mode == 'select') modes.set.insertSet mode to Insert -modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select') +modes.set.normalSet mode to NormalEscape (editorTextFocus && dance.mode == 'insert')Escape (editorTextFocus && dance.mode == 'select')V (editorTextFocus && dance.mode == 'select')Ctrl+[ (editorTextFocus && dance.mode == 'insert') modes.set.selectSet mode to SelectV (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.insertTemporary Insert modeCtrl+V (editorTextFocus && dance.mode == 'normal') modes.set.temporarily.normalTemporary Normal modeCtrl+V (editorTextFocus && dance.mode == 'insert') @@ -910,11 +910,11 @@ Set Dance mode. #### Variants -| Title | Identifier | Keybinding | Command | -| ------------------ | ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | -| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | -| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | -| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | +| Title | Identifier | Keybinding | Command | +| ------------------ | ------------ | --------------------------------------------------------------------------------- | ----------------------------------------------------------- | +| Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select), `c-[` (core: insert) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | +| Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | +| Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | Other variants are provided to switch to insert mode: diff --git a/src/commands/modes.ts b/src/commands/modes.ts index 9c491e82..1a114694 100644 --- a/src/commands/modes.ts +++ b/src/commands/modes.ts @@ -11,11 +11,11 @@ declare module "./modes"; * * #### Variants * - * | Title | Identifier | Keybinding | Command | - * | ------------------ | ------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | - * | Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | - * | Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | - * | Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | + * | Title | Identifier | Keybinding | Command | + * | ------------------ | ------------ | --------------------------------------------------------------------------------- | ----------------------------------------------------------- | + * | Set mode to Normal | `set.normal` | `escape` (core: insert; helix: select), `v` (helix: select), `c-[` (core: insert) | `[".modes.set", { mode: "normal" }], ["hideSuggestWidget"]` | + * | Set mode to Insert | `set.insert` | | `[".modes.set", { mode: "insert" }]` | + * | Set mode to Select | `set.select` | `v` (helix: normal) | `[".modes.set", { mode: "select" }]` | * * Other variants are provided to switch to insert mode: *