Skip to content

Instantly share code, notes, and snippets.

@neuromaancer
Last active August 28, 2023 05:54
Show Gist options
  • Select an option

  • Save neuromaancer/9bc000265d6d773d3c1170d66a5ada3f to your computer and use it in GitHub Desktop.

Select an option

Save neuromaancer/9bc000265d6d773d3c1170d66a5ada3f to your computer and use it in GitHub Desktop.

Revisions

  1. neuromaancer revised this gist Aug 28, 2023. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions oveleaf_vim_keybinds.js
    Original file line number Diff line number Diff line change
    @@ -26,5 +26,8 @@

    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");
    });
    })();
  2. neuromaancer created this gist Aug 17, 2023.
    30 changes: 30 additions & 0 deletions oveleaf_vim_keybinds.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    // ==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");
    });
    })();