Skip to content

Commit

Permalink
Merge pull request #69 from asford/leave_current_mode
Browse files Browse the repository at this point in the history
Add "leave-current-mode" command to move insert->normal->command.
  • Loading branch information
krassowski authored Mar 12, 2023
2 parents 95da6de + ed56d27 commit bdcebe3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# History

## Next
* Add bindable command to move insert-to-normal-to-command modes (#69)

## 0.15.1 / 2022-03-12
* Fixed a bug in `0.15.0` where you could no longer type `c`.
Expand Down
24 changes: 24 additions & 0 deletions src/labCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,30 @@ export function addJLabCommands(
},
isEnabled
}),
commands.addCommand('vim:leave-current-mode', {
label: 'Move Insert to Normal to Jupyter Command Mode"',
execute: args => {
const current = getCurrent(args);

if (current) {
const { content } = current;
if (content.activeCell !== null) {
const editor = content.activeCell.editor as CodeMirrorEditor;

// Get the current editor state
if (
editor.editor.state.vim.insertMode ||
editor.editor.state.vim.visualMode
) {
(CodeMirror as any).Vim.handleKey(editor.editor, '<Esc>');
} else {
commands.execute('notebook:enter-command-mode');
}
}
}
},
isEnabled
}),
commands.addCommand('vim:select-below-execute-markdown', {
label: 'Execute Markdown and Select Cell Below',
execute: args => {
Expand Down

0 comments on commit bdcebe3

Please sign in to comment.