overleaf clopnaz

does :set tabstop=2 and :set softtabs in Overleaf's vim editor

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         overleaf clopnaz
// @namespace    http://tampermonkey.net/
// @version      1.0
// @match        https://www.overleaf.com/project/*
// @grant        none
// @description  does :set tabstop=2 and :set softtabs in Overleaf's vim editor
// ==/UserScript==

// In overleaf's vim editor (see 'ACE'), you can't do many ':' commands
// this script changes the tabwidth to 2 and uses spaces instead of tabs
// there's some additional commented code that should help with remapping as well
(function() {
    'use strict';
    // get the ACE editor so we can modify settings
    const retry = setInterval(() => {
        if (window._debug_editors[window._debug_editors.length -1].session === undefined) return
        clearInterval(retry) // poll until editor is loaded
        // get current editor instance
        const editor = window._debug_editors[window._debug_editors.length -1]
        // vim keyboard plugin
        
        ace.config.on("session", function(session) {
            //    session.setOption("wrap", 80) // This may break auto-completion.
            // session.setWrapLimitRange(80, 80) //Caveat: no more wrap to the pane of size smaler than 80 col.
            session.setOption('tabSize',2) // set the width of tabs to 2 
            session.setOption('useSoftTabs', true) // use soft tabs 
            console.log("Custom tabwidth applied")
        })
        // // add custom keybindings - insert mode applies on insert
        // vimKeyboard.Vim.map("jj", "<Esc>", "insert")
        // // normal mode applies while escaped
        // vimKeyboard.Vim.map("h", "j", "normal")
        // // set the modified keyboard handler for editor
        // editor.setKeyboardHandler(vimKeyboard.handler)
        

    }, 100)
})();