forked frombrijeshb42/monaco-emacs
- Notifications
You must be signed in to change notification settings - Fork1
Emacs keybindings for monaco-editor
License
NotificationsYou must be signed in to change notification settings
LeetCode-OpenSource/monaco-emacs
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Emacs key bindings for monaco-editor.Demo.
npm install monaco-emacs
import*asmonacofrom'monaco-editor';import{EmacsExtension}from'monaco-emacs';
- Add this script in your html -
https://unpkg.com/monaco-emacs/dist/monaco-emacs.js. - The extension will be available as
MonacoEmacsonwindow
constmonaco=window.monaco;const{ EmacsExtension}=window.MonacoEmacs;
consteditorNode=document.getElementById('editor');conststatusNode=document.getElementById('statusbar');consteditor=monaco.editor.create(editor);constemacsMode=newEmacsExtension(editor);emacsMode.onDidMarkChange((ev:boolean)=>{statusNode.textContent=ev ?'Mark Set!' :'Mark Unset';});emacsMode.onDidChangeKey((str)=>{statusNode.textContent=str;});emacsMode.start();// If you want to remove the attached bindings, callemacsMode.dispose();
import{unregisterKey}from'monaco-emacs';unregisterKey('Tab');
import{getAllMappings}from'monaco-emacs';console.log(getAllMappings());
If you are following the official guide and integrating the AMD version ofmonaco-editor, you can follow this -
<!DOCTYPE html><html><head><metahttp-equiv="X-UA-Compatible"content="IE=edge"/><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"></head><body><divid="container"style="width:800px;height:600px;border:1px solid grey"></div><divid="status"></div><scriptsrc="https://unpkg.com/monaco-editor/min/vs/loader.js"></script><script>require.config({paths:{'vs':'https://unpkg.com/monaco-editor/min/vs','monaco-emacs':'https://unpkg.com/monaco-emacs/dist/monaco-emacs',}});require(['vs/editor/editor.main','monaco-emacs'],function(a,MonacoEmacs){vareditor=monaco.editor.create(document.getElementById('container'),{value:['function x() {','\tconsole.log("Hello world!");','}'].join('\n'),language:'javascript'});varstatusNode=document.getElementById('status');varemacsMode=newMonacoEmacs.EmacsExtension(editor);emacsMode.onDidMarkChange(function(ev){statusNode.textContent=ev ?'Mark Set!' :'Mark Unset';});emacsMode.onDidChangeKey(function(str){statusNode.textContent=str;});emacsMode.start();// remove emacs mode by calling// emacsMode.dispose();});</script></body></html>
Pleasereport any inconsistencies or missing key bindings.
About
Emacs keybindings for monaco-editor
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Languages
- TypeScript94.8%
- JavaScript4.3%
- HTML0.9%