Skip to content

Instantly share code, notes, and snippets.

@manchitro
Last active April 4, 2024 17:49
Show Gist options
  • Save manchitro/e7af536b287b48a47da055c476d9e8b5 to your computer and use it in GitHub Desktop.
Save manchitro/e7af536b287b48a47da055c476d9e8b5 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Overleaf Editor Custom VIM Keybindings
// @namespace http://tampermonkey.net/
// @version 0.1
// @match https://www.overleaf.com/project/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener("UNSTABLE_editor:extensions", (event) => {
const { CodeMirror, CodeMirrorVim, extensions } = event.detail;
// add custom keybindings - insert mode applies on insert
CodeMirrorVim.Vim.map("kj", "<Esc>", "insert");
// normal mode applies while escaped
CodeMirrorVim.Vim.map("H", "^", "normal");
CodeMirrorVim.Vim.map("L", "$", "normal");
// visual mode mappings
CodeMirrorVim.Vim.map("H", "^", "visual");
CodeMirrorVim.Vim.map("L", "$", "visual");
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment