Skip to content

Instantly share code, notes, and snippets.

@cyrillkuettel
Created November 26, 2022 15:30
Show Gist options
  • Save cyrillkuettel/55a9feb51c6f2e027ccd9918cc1b0936 to your computer and use it in GitHub Desktop.
Save cyrillkuettel/55a9feb51c6f2e027ccd9918cc1b0936 to your computer and use it in GitHub Desktop.
Demonstrates how to inject custom vim settings in CodeMirror 6 Editor.
// ==UserScript==
// @name Overleaf Custom Vim bindings
// @match https://www.overleaf.com/project/*
// @version 0.1
// @description Injecting custom vim settings in overleaf project. CodeMirror 6 editor only.
// @author cyrillkuettel
// @match https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo/related?hl=de
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener('UNSTABLE_editor:extensions', (event) => {
const retry = setInterval(() => {
//console.log(event);
const { CodeMirrorVim, extensions } = event.detail
if (CodeMirrorVim.Vim == undefined) {
return;
}
CodeMirrorVim.Vim.map('jk', '<Esc>', 'insert')
console.log("Custom key bindings applied")
}, 100);
})
})();
@cyrillkuettel
Copy link
Author

How to use

  • Download a browser extension (Like Tampermokey) that allows executing custom javascript on a per-site basis.
  • Add a Userscript: Paste the text above.

Note: The api is unstable and subject to change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment