Skip to content

Commit

Permalink
Add vim key mapping 'jj' for insert mode
Browse files Browse the repository at this point in the history
  • Loading branch information
choidabom committed Sep 7, 2024
1 parent 4553a6e commit cb69240
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/components/editor/Editor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { markdown } from "@codemirror/lang-markdown";
import { EditorState } from "@codemirror/state";
import { keymap } from "@codemirror/view";
import { vim } from "@replit/codemirror-vim";
import { Vim, vim } from "@replit/codemirror-vim";
import { xcodeDark, xcodeLight } from "@uiw/codemirror-theme-xcode";
import { basicSetup, EditorView } from "codemirror";
import { useCallback, useEffect, useState } from "react";
Expand Down Expand Up @@ -86,8 +86,10 @@ function Editor() {
],
});

const view = new EditorView({ state, parent: element });
// Vim key mapping: Map 'jj' to '<Esc>' in insert mode
Vim.map("jj", "<Esc>", "insert");

const view = new EditorView({ state, parent: element });
dispatch(setCmView(view));

return () => {
Expand Down

0 comments on commit cb69240

Please sign in to comment.