Can Vim mode keybindings in the web app be customized using TamperMonkey (or similar)?

Overleaf lets you use TamperMonkey to customize vim mode keybindings as described here:

https://www.overleaf.com/learn/how-to/How_can_I_define_custom_Vim_macros_in_a_vimrc_file_on_Overleaf%3F

Is there any way to get this kind of thing working on Typst as well? I’ve tried to play around with the script but haven’t managed to get it working yet.

I don’t think so. AFAIK, the creators don’t use Vim at all, so extensive Vim support isn’t something that is top priority.

From Vimrc and Langmaps · Issue #366 · typst/webapp-issues · GitHub :

We use @replit/codemirror-vim […]

So you can try something out knowing the implementation that is used under the hood.

Generally, for those rare occasions when I do have to use the web version, the default Vim mode is enough for most stuff. However, for others sites I switch to using GitHub - fregante/GhostText: 👻 Use your text editor to write in your browser. Everything you type in the editor will be instantly updated in the browser (and vice versa).. I use Neovim, btw, and I just tried using this with Typst web app:

If you disconnect, it looks like the plugin breaks, and you need to reload the page (normally it just works, I think). But a huge advantage that I didn’t know is that you can connect to multiple files and modify all of them without touching the browser! This means, for example, if I connect to main.typ, create and connect to other.typ, then I can type in both buffers and all the changes will apply in real time. I can, for example, do #include "other.typ" in main.typ and write something in other.typ then it will show this in the preview, even though visually the other.typ file is selected in the web app (not main.typ). I think this is a huge productivity boost as you don’t need to constantly click between files in the web app and just switch between them in your editor.

1 Like

Thanks for the answer! Yeah I’ve seen those issues, definitely doesn’t seem to be a priority which is why I was looking for some hacky fix. I’ll definitely check out GhostTest though, sounds promising.

If you feel like this answers your question, please mark it as a solution to help others find the answer more quickly.