Created
January 26, 2022 09:46
-
-
Save hslyu/6e5de9dd9eb4e9cb8dc34b85f0ed74f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Overleaf jump $ | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @match https://www.overleaf.com/project/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// poll until editor is loaded | |
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") | |
// add custom keybindings - insert mode applies on insert | |
vimKeyboard.Vim.map(";", "f$a", "normal") | |
// normal mode applies while escaped | |
vimKeyboard.Vim.map(";", "<esc>;", "insert") | |
vimKeyboard.Vim.map("{", "{}", "insert") | |
vimKeyboard.Vim.map("(", "()", "insert") | |
// set the modified keyboard handler for editor | |
editor.setKeyboardHandler(vimKeyboard.handler) | |
console.log("Custom key bindings applied") | |
}, 100) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment