Show HN: Vim online editor using WebAssembly, storing files using IndexedDB
vimonlineeditor.com
vimonlineeditor.com
A month ago I did find what I consider to be even better : make of any textarea on any page a neovim instance with the firenvim extension (thanks to which I am writing this comment in neovim in my browser!)
It's not even a vim-like experience, it's literally your configured neovim in the browser !
Somehow I haven't managed to get it to the front page (this is not my creation but I am a big fan since I have been looking for this for so long)
I even get autocompletion and all coding niceties in the little code playgrounds that are all the rage in nowadays tutorials
If that simple feature gets implemented there'll be at least one more FF user in yours truly. :)
Wrote a file to test.js with the following:
console.log(navigator)
document.querySelector("#pastebtn").innerText = "PASTE"
And then run it with `:!test.js` and it executes it in the current browser context. Editor editing itself :)If so, Indexeddb should only be used to store “unsaved” files for safari.
Chrome and Firefox support https://caniuse.com/mdn-api_permissions_persistent-storage_p...
But that implies if the user denies persistent storage, then indexedb should be again only used to store “unsaved” files
(I say “their version” because they still lack a number of things most PWAs use, like more robust service workers for background operations, notification support, etc)
A few months ago, I decided to play around with IndexedDb (for the first time) and PWAs and created a Stable Diffusion web interface that stores data in your browser. [1]
I have thousand of images stored as base64 strings in Safari on iOS since the beginning of October and it’s all still there!
Granted… this is a web app installed as an “app” on my iPhone’s Home Screen. So, IndexedDb inside Safari itself may still behave as you say.
It was recently written up in PC World [2] as part of an article about a distributed cluster of Stable Diffusion instances [3].
[1] https://tinybots.net/artbot
[2] https://www.pcworld.com/article/1431633/meet-stable-horde-th...
Perfect :
* Using :left and V , set ts=4 sts=4 sw=4
* Recording macros with q
* Main vim combos - it's definitely vim
Fails :
* Typing { or } on a MacBook Air under Firefox - don't know which of this settings cause the bug. Reproducibly, { does not work
* Replaying a macro containing { or any error
Kudos for the compilation (emscripten ?) and Brace for impact (the incoming bugs) :)
What I'd really like to see return is an online version of EDIT.COM, and maybe also its host binary QBASIC.EXE, not just for the nostalgia but because it was a pretty decent editor for the time, it even supported editing binary files if you didn't have a hex editor to hand, though you had to use Alt+(numpad) for most characters.
Also, I use ctrl-[ as escape, and it seems to catch it sometimes, otherwise inserting an actual "ctrl-[" character.
On Firefox btw.
Does this open up an attack surface on users using vim/neovim? This page seems to indicate that neovim (and this) do not run in a sandbox already.
Can anyone with more knowledge on this expand on that?
Note that this seems to work much better in Chrome than in Firefox - when I press Ctrl in Firefox, it activates Visual Block mode (so e.g. Ctrl-D, Ctrl-U, Ctrl-O, Ctrl-I won't work).
We're building out a free AI code completion tool, Codeium that will support Neovim as an IDE and would love to hook into this as well.
[0]: https://github.com/tpope/vim-sensible/blob/master/plugin/sen...
Only FreeBSD, in my easily ssh'able world, has real Bill Joy (et al) vi.
I use vim locally, for everyday coding; it didn't occur to me that you could be using vi/vim only occasionally, I assumed vi is your main editor (:
WASM would help with that.
> Wasm is 1.95-11.71x faster than JavaScript on Firefox
> Wasm is 1.15-1.67x faster than JavaScript on Google Chrome
> Wasm is 1.02-1.38x faster than JavaScript on Safari on
To answer the question that you implied ("why can't vscode be compiled to wasm for performance"): vscode is built at least in part on dynamic languages. There's no compiler for JavaScript (or Python, or Ruby) to WASM, you can only compile the interpreter for these languages to WASM and then run your code in the compiled interpreter. This would be slower than what exists today because it's not replacing the traditionally-slow bits with WASM, it's replacing the fast, native bits with WASM.
The reason there are no compilers for dynamic languages is the same reason you can't compile (the full, canonical) JavaScript/Python/etc. to native code: the dynamic nature of the language prevents the generation of efficient CPU instructions. You'd need to do one of a few things:
1. Rewrite the dynamic code to not use the features that do not compile well to native code. Then write a compiler to compile the efficient subset of your language to native code. This is hard and bad because why use a dynamic language in the first place? You can see examples of this in projects like AssemblyScript and LLJS (for Python, see RPython).
2. Compile everything you can to efficient native code, then make the dynamic bits use less efficient code that does work at runtime that other languages could do at compile time. This is AOT compilation, and building an AOT compiler is hard. Building an AOT compiler that works well for most code is extremely hard. Additionally, you couldn't do things like load dynamic code at runtime (e.g., plugins).
3. Write a compiler that interprets the dynamic code at runtime, and dynamically compiles that code to native code as it is able to identify bits that can be efficiently run on the CPU. This is JIT compilation, and building a JIT compiler is hard. Moreover, you can't do JIT compilation in WASM because it would require WASM to have an API for this, and that seems unlikely right now.
4. Just use a different, more efficient language.
So to answer your question, "why not compile vscode to wasm for performance improvements?" You could, but it wouldn't be faster. Or, you'd rewrite it in a different language, but then it wouldn't be vscode anymore.
You can even use the VSCodeVim extension (minus neovim-powered features) inside it. You can turn on Settings sync and it will share as many extensions as it can with your Desktop setup, and also your theme and other stuff.
VSCode.dev has a really cool Theme Playground. For instance, if you were curious to see what my current "synthwave-inspired" theme that I like to use looks like (with a variety of different file types open): https://vscode.dev/theme/jaredkent.laserwave
The more interesting and generally most useful way to get to VSCode.dev is from GitHub or Azure Repos. Use the keyboard shortcut "." in a repo file listing to open that Repo on the web in VSCode.dev (or GitHub uses GitHub.dev but it is the same VS Code tech).
> Why use Vim Online Editor?
> 1. Because you love vim.
> 2. Because you don't have access to vim somehow (maybe you're on a Chromebook that doesn't allow access to the system)
> 3. Especially if you're on Windows and you still want to use vim.
> 4. Because you want a notepad of some sort in the browser, and you want to use vim bindings instead of normal notepad.
Last time I was actively using Windows was in the late WinXP / early Win7 era. But I don’t see why Win 10 / 11 would make running Vim difficult.
I do agree with all of the other points though.
As a heavy vim user, I've literally been using gvim.exe every day on Windows for the past decade