uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.65k stars 132 forks source link

Use vim mode #331

Closed barreiros closed 2 years ago

barreiros commented 2 years ago

Hi!

Can I use keymap/vim? I've tried to pass the param keymap in multiples ways...

<CodeMirror 
  value={code} 
  onChange={setCode} 
  onViewChanged={setView} 
  options={{
    theme: 'monokai',
    keyMap: 'sublime',
    mode: 'jsx',
  }
}/>
<CodeMirror 
value={code} 
onChange={setCode} 
onViewChanged={setView} 
keymap="vim"
}/>

...but the browser returns

ReferenceError: CodeMirror is not defined`

Thanks!

jaywcjlove commented 2 years ago

You can provide an example using codesandbox.io.

@barreiros

barreiros commented 2 years ago

Here your are the example with the keymap folder in public folder.

Thanks!

jaywcjlove commented 2 years ago

@barreiros example: https://codesandbox.io/embed/react-codemirror-example-codemirror-6-forked-uby11k?fontsize=14&hidenavigation=1&theme=dark

import React from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";

import { vim } from "@replit/codemirror-vim";

export default function App() {
  return (
    <div>
      <CodeMirror
        value="console.log('hello world!');"
        height="200px"
        theme="dark"
        extensions={[vim(), javascript({ jsx: true })]}
        onChange={(value, viewUpdate) => {
          console.log("value:", value);
        }}
      />
    </div>
  );
}
barreiros commented 2 years ago

Great!

Thanks, @jaywcjlove

prmichaelsen commented 2 years ago

is there anyway to disable 'esc' behavior blurring the editor. I know C-c works but a having to use two keys for a common use case is very "anti-vim"