
Vim.wasm: Vim Ported to WebAssembly - comepradz
https://github.com/rhysd/vim.wasm
======
flohofwoe
Looks like this is mostly running interpreted "Emterpreter" byte code (the
.wasm blob is about 52 KByte, but there's a 1.9MBytes emterpretify.data file,
which (I guess from the size) contains the bulk of the logic. If this is
indeed true it doesn't really use WebAssembly's strengths, since only the
bytecode interpreter is running in WebAssembly, while vim itself is running
interpreted.

Emterpreter was added to emscripten to workaround the problem in the browser
runtime that you can't execute long-running blocking functions from within the
browser loop. Emterpreter essentially allows to yield and continue from the
middle of C code, however it's intended to only run as little code as possible
like this (for instance only in the outer event-loop of an application), and
call into asm.js or wasm code, where the actual work should happen.

Again, whether this vim demo works like this is speculation on my side, based
on the relative sizes of the .wasm and emterpretify.data file sizes :)

------
royjacobs
Oh great, soon I won't even know how to exit my _browser_ anymore :)

~~~
tomcam
Don’t be silly. There will soon be 3 poorly-written plug-ins that will give
you almost the exit functionality you want, all with overlapping yet
incomplete features.

------
throwaway2016a
It's a little buggy, but being both a vim and web fan I like the idea.

With that said, does anyone have insight in how porting something like this
works? Are there terminal emulator libraries already for WASM or did they need
to make their own?

Vim is an interesting case because unlike terminal programs that run in
sequence, vim needs to redraw any part of the screen at any time. It strikes
me as being more complicated.

I noticed there are some terminal libraries in there but they have
modifications and I don't know enough to know if those are standard or the
author needed to invent something.

~~~
WalterGR
I’ve been wondering the same thing, for my project idea #517 of porting Emacs
to WASM.

If you find any more info, it’d be awesome if you commented again.

------
mcjiggerlog
This looks really promising!

There are a few things that don't seem to work, e.g. `ciw`.

------
keithnz
ok, that's pretty cool! Some things are a bit slow like character repeat is a
bit wonky, help doesn't seem to work... but otherwise, seems like vim to me

------
cmsj
I'll admit up front to being a wasm cynic, but what exactly is the point of
having a text editor trapped in a browser sandbox?

~~~
icc97
Well if nothing else Vim is very nice for modifying text strings. So for
example I might be writing some markdown for a Stack Overflow answer / GitHub
issue, if I can quickly open a tab in my browser format all the text nicely -
e.g. indenting all the code 4 spaces in for SO and then yank and paste it back
into SO. You don't ever need to leave the context of the browser and you get
some added text formatting properties.

It's probably not a huge benefit, but in the same way you can often SSH into
somewhere open up Vim make a change and then leave, I can see it being a nice
'clipboard' for my web text. It's not a lot different just to switching to Vim
running on your desktop, but I often keep Vim in a separate virtual desktop. I
could then also potentially optimise by browser Vim for formatting Markdown /
JSON.

It also shows some of the lovely flexibility of Vim.

~~~
craftyguy
May as well use a browser with native vim bindings/behaviors (i.e.
qutebrowser)

~~~
icc97
That doesn't give you a nice scratch pad / clipboard though.

Plus the browser bindings are never quite right. Although this implementation
is a bit buggy, it's actual Vim. So where as it might not have things like
multiple buffers, just being able to edit a single buffer in a familiar
environment is a really nice feature to have.

I'm certainly going to give this a shot when I next add an answer to SO.

------
guiampm
Ok now, how do you exit it?

~~~
vlucas
Close the browser tab :)

~~~
guiampm
I was expecting a solution from StackOverflow and involved Jquery somehow :o

