-
-
Save aalok-sathe/a5dab9274ac881bd20418a3530fbca70 to your computer and use it in GitHub Desktop.
Overleaf j k remap
This file contains hidden or 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: map j to gj and k to gk | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.2 | |
| // @match https://www.overleaf.com/project/* | |
| // @grant none | |
| // @description Remap j/k to gj/gk in Overleaf Vim normal/visual modes | |
| // @downloadURL https://gist.githubusercontent.com/aalok-sathe/a5dab9274ac881bd20418a3530fbca70/raw/2f531157d115fd4010f6dc631cd4f1f086e41299/overleaf-remap.js | |
| // @updateURL https://gist.githubusercontent.com/aalok-sathe/a5dab9274ac881bd20418a3530fbca70/raw/2f531157d115fd4010f6dc631cd4f1f086e41299/overleaf-remap.js | |
| // ==/UserScript== | |
| //Based on code from https://www.overleaf.com/learn/how-to/How_can_I_define_custom_Vim_macros_in_a_vimrc_file_on_Overleaf%3F | |
| (function() { | |
| 'use strict'; | |
| window.addEventListener("UNSTABLE_editor:extensions", (event) => { | |
| const { CodeMirror, CodeMirrorVim, extensions } = event.detail; | |
| // normal mode applies while escaped | |
| CodeMirrorVim.Vim.map("j", "gj", "normal"); | |
| CodeMirrorVim.Vim.map("k", "gk", "normal"); | |
| CodeMirrorVim.Vim.map("$", "g$", "normal"); | |
| CodeMirrorVim.Vim.map("^", "g^", "normal"); | |
| CodeMirrorVim.Vim.map("j", "gj", "visual"); | |
| CodeMirrorVim.Vim.map("k", "gk", "visual"); | |
| CodeMirrorVim.Vim.map("$", "g$", "visual"); | |
| CodeMirrorVim.Vim.map("^", "g^", "visual"); | |
| }); | |
| })(); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated fork to also support remapping
$to work per-softwrapped-line