Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set keyMap on codemirror editor to make use of other key bindings #124

Open
Steve-Mcl opened this issue Oct 22, 2019 · 2 comments
Open
Labels

Comments

@Steve-Mcl
Copy link

Is there a way to set a keyMap on the underlying codemirrior editor?

Example using sublime mapping https://codemirror.net/demo/sublime.html

  • See how ctrl+d selects multiple items for multi cursor editing
  • see how ctrl+shift+down moves a line down
  • and a ton of other useful key shortcuts.

If you check the source of that demo, you'll see keymap is set at instantiation time...

var editor = CodeMirror(document.body.getElementsByTagName("article")[0], {
  value: value,
  lineNumbers: true,
  mode: "javascript",
  keyMap: "sublime",
  autoCloseBrackets: true,
  matchBrackets: true,
  showCursorWhenSelecting: true,
  theme: "monokai",
  tabSize: 2
  });

... other sources show you can also call CodeMirror.setOption with "keyMap" or addKeyMap

However, If I include /keymap/sublime.js in my html, I get an error due to CodeMirror not being exposed by EasyMDE

Thanks for any support or advice you can offer.

@mxgl
Copy link

mxgl commented Mar 9, 2020

codemirror is exposed

if your easymde instance is myMDE

myMDE.codemirror gives you all your codemirror stuff.

@kolaente
Copy link

I got

TypeError: can't access property "attach", next is undefined
    defineOptions codemirror.js:7725
    operation codemirror.js:3925
    setOption codemirror.js:8229
    bindingEvents index.vue:116
    initialize index.vue:96
    mounted index.vue:58

when trying to execute this.easymde.setOption('keyMap', 'vim').

(using in combination with this vue plugin - could be a problem on their side)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants