// ==UserScript==
|
|
// @name Overleaf vimrc
|
|
// @namespace fr.homnomnom
|
|
// @version 0.1
|
|
// @description Custom vimrc for CodeMirror
|
|
// @author n0m1s
|
|
// @match https://www.overleaf.com/project/*
|
|
// @grant none
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
const retry = setInterval(() => {
|
|
if (window._debug_editors === undefined) return;
|
|
clearInterval(retry);
|
|
// get current editor instance
|
|
const editor = window._debug_editors[window._debug_editors.length -1];
|
|
|
|
// vim keyboard plugin
|
|
const vimKeyboard = window.ace.require("ace/keyboard/vim");
|
|
vimKeyboard.Vim.map(",,", "<Esc>", "insert");
|
|
vimKeyboard.Vim.map(".", ":", "normal");
|
|
|
|
// set the modified keyboard handler for editor
|
|
editor.setKeyboardHandler(vimKeyboard.handler);
|
|
console.log("Custom key bindings applied");
|
|
}, 100);
|
|
})();
|