Last active
August 28, 2023 05:54
-
-
Save neuromaancer/9bc000265d6d773d3c1170d66a5ada3f to your computer and use it in GitHub Desktop.
Overleaf Editor Custom VIM Keybindings
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 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("jk", "<Esc>", "insert"); | |
// normal mode applies while escaped | |
CodeMirrorVim.Vim.map("j", "gj", "normal"); | |
CodeMirrorVim.Vim.map("k", "gk", "normal"); | |
CodeMirrorVim.Vim.map("j", "gj", "visual"); | |
CodeMirrorVim.Vim.map("k", "gk", "visual"); | |
CodeMirrorVim.Vim.map("H", "g^", "normal"); | |
CodeMirrorVim.Vim.map("L", "g%", "normal"); | |
CodeMirrorVim.Vim.map("H", "g^", "visual"); | |
CodeMirrorVim.Vim.map("L", "g%", "visual"); | |
//delete the {}, [] | |
CodeMirrorVim.Vim.map("sd{", "di{va{p", "normal"); | |
CodeMirrorVim.Vim.map("sd[", "di[va[p", "normal"); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment