
Vim.wasm - fibo
https://rhysd.github.io/vim.wasm/
======
nyx_
I thought I was getting stuck in insert mode, and I got fairly frustrated
before realizing my Vim keybindings browser extension was grabbing ESC and
keeping it from this weird browser-Vim.

We brought this abomination on ourselves.

~~~
nnq

      Ctr+[
    

Vim-ing on devices with not physical Esc key makes you get used to this
(default configured, no extra keymapping required) Esc alternative :P

~~~
latexr
I really dislike shortcuts with `[` and similar keys. Design software also
tends do use them. On a Portuguese keyboard layout[1], I need to press ⌥8 to
get `[`. So shortcuts like ⌃[ become ⌃⌥8, which in vim produces `8`.

[1]:
[https://en.wikipedia.org/wiki/File:KB_Portuguese.svg](https://en.wikipedia.org/wiki/File:KB_Portuguese.svg)

~~~
yoodenvranx
That's why I use the EurKEY [1] layout on all my machines!

This way I can use all the default US-based shortcuts for emacs/vim/... while
still being able to easily type the special chars for my native language, e.g.
pressing AltGr+o results in 'ö'.

This method is slightly inconvenient for typing long texts but for me it's
still the perfect solution to such problems.

[1]:
[https://eurkey.steffen.bruentjen.eu/start.html](https://eurkey.steffen.bruentjen.eu/start.html)

~~~
reirob
I was not aware of this, but found a similar solution that is available almost
on any computer: On Linux (my main work environment) I use the English
International with AltGr Dead Keys. This gives me a lot of European (and
other) accents by combining AltGr+<Accent simulation key> <Letter on which to
put the accent>.

Examples:

ä - AltGr+" a (the double quote looks visiually like 2 dots)

ç - AltGr+, c

õ - AltGr+~, o

and so on. I found this solution very practical, even if quite late in my life
(went from German QWERTZ, to French AZERTY, to end up with QWERTY), because
QWERTY is available everywhere, even if I have to work remote through Windows
computers, and it is much much friendlier than AZERTY/QWERTZ. Additionally it
gives me to write with the same layout German, French, Portuguese, etc. And it
is very easy to remember how to get the accents, because the used signs are
visually close.

------
tomjakubowski
Does anyone know if lynx plans on supporting wasm? I'd like to try this editor
in a terminal.

~~~
halter73
At this point, the easier route to getting a text-based browser to support
something like this would be creating a new one based on WebKit/Blink.

It would probably need to get the engine to draw to a fake screen buffer and
run an OCR algorithm over that. And even if the OCR and layout worked well,
there would be a lot other work necessary to get reasonable text based
interactivity, though that's probably partially solved by projects like
Vimium. Some interactions like dragging would likely never be supported.

Not easy at all, but somehow more reasonable than updating lynx to support all
of today's new technologies. I wonder if anyone's already tried something like
it.

~~~
aasasd
> _OCR_

Hey, dial back the blasphemy there. HTML is not PDF, it's usually made from
text in the first place.

I'd guess you could force all text to use a monospace font, with fixed
measures and line-height, and limit the width of the page. Then mostly dump
the resulting text arrangement into the terminal.

Now, layouts from the various elements and CSS are probably a lot trickier,
but snapping all margins and padding to multiples of a symbol's size should go
a long way.

It seems that this could even be embedded at different levels in the browser:
the layout engine or just the user's JS. (If JS can obtain the exact layout of
text lines and elements―likely not, though, especially in forms. Maybe via
devtools.)

~~~
_pmf_
> HTML is not PDF, it's usually made from text in the first place.

I don't know, man. Most websites would be smaller if they were replaced by a
HD video of someone reading the contents.

------
AndyKelley
The GitHub readme has a bunch of great content on it.
[https://github.com/rhysd/vim.wasm](https://github.com/rhysd/vim.wasm)

------
be_erik
This is absolutely incredible. I never thought this would be possible-- wasm
opens a new phase of software development and deployment.

~~~
techntoke
Or just use regular Vim and not think that everything needs to run inside of a
web browser, especially if you value user privacy and computer resources.

~~~
orev
Would be nice to be able to use vim (or any other editor of your choice) in
web text boxes.

~~~
opan
This is the logic that makes everyone move their workflow into emacs. A lot of
what we do is text editing, so having a good text editor everywhere makes
sense. Some programs like mutt can also drop in to your editor of choice when
composing an email. Imagine if we all had vim for typing up these HN comments.
I'd like something like this to be more feasible. Maybe there could be a
standard for forums that gives you vim editing in the same way many give you
markdown. It could also be cool to support org-mode syntax.

~~~
feanaro
Imagine if programs knew how to interact with one another and could plumb data
between them instead of everything living in one monolithic application.

------
frutiger

      :colorscheme
      unknown                       "that's weird
      :set file^I^I                 "I guess tab autocomplete doesn't work
      :set filetype=cpp
      i#include <iostream><Esc>     "I guess syntax highlighting doesn't work either
      :set tabstop=4 softtabstop=4
      i^I^I                         "at least that worked!

------
kalefranz
Where’s the escape key on my iPhone?

~~~
sbr464
Try:

Ctrl and [

That should send the same as Esc (ASCII 27).

I seem to remember this working on a new iPad Pro keyboard.

~~~
no-such-address
This is incredible. I think I needed this about 40 years when typing on a
small Teletype (non-ASR33) without an escape key.

~~~
midgetjones
The reason is interesting as well. Paraphrasing from this blog post[0]

When you format the ASCII table in four columns, you can see `ESC` and `[` on
the same row. Holding `CTRL` essentially ~lops off the first three bits~
subtracts 64, resulting in `ESC`

    
    
       ...
       ...
       0011000 CAN    0111000 8    1011000 X    1111000 x
       0011001 EM     0111001 9    1011001 Y    1111001 y
       0011010 SUB    0111010 :    1011010 Z    1111010 z
       0011011 ESC    0111011 ;    1011011 [    1111011 {
       0011100 FS     0111100 <    1011100 \    1111100 |
       0011101 GS     0111101 =    1011101 ]    1111101 }
       0011110 RS     0111110 >    1011110 ^    1111110 ~
       0011111 US     0111111 ?    1011111 _    1111111 DEL
    
    

[0] [http://www.catb.org/esr/faqs/things-every-hacker-once-
knew/](http://www.catb.org/esr/faqs/things-every-hacker-once-knew/)

~~~
jcr1488
> Holding `CTRL` essentially lops off the first three bits

No, it inverts the 7th bit (or subtracts 64).

The Linux `ascii(7)` man page has a similar table, but with 2 columns. The
first 32 control characters listed there have their "caret notation" character
in the opposite column.

~~~
nothrabannosir
Is this why the symbol for Ctrl is also commonly the symbol for xor?!

~~~
jcr1488
I'm not sure. I think the caret is just a prefix to make it distinguishable
from the normal letters.

It is the reason why Ctrl+i in a terminal is the same as Tab though. Likewise
for Ctrl+m == Enter.

------
monokrome
This is pretty dope, but I'm terrified about the fact that Firefox lets it
take over Ctrl+L, Ctrl+1, or any other way (that I can find, at least) of
breaking out of Vim with a keyboard aside from closing the tab with Ctrl+W -
which is even more terrifying since I use that in Vim a ton, too :O

...but this _is_ pretty cool :D

~~~
aasasd
The actual issue is that Windows and Linux don't properly use a ‘super’
key―while the ‘Win’ key is sitting there uselessly.

Ironically, MS' own ‘ergonomic’ _(cough)_ keyboards have gigantic Win keys,
right under the thumbs which are the strongest digits. These keys are _great_
to use on Mac, it's an eye-opener as to how the historical keyboard mutations
ended up in just the wrong way for two platforms (and for Emacs).

I could also say some things about the nonsensical shape of keyboards and the
moronic replication of the typewriters' staggered key layout...

~~~
hjk05
I’d love to hear your take on the nonsensical shape and staggered key layout.
Do you have suggestions for keyboards that do away with this?

I have myself been looking at [https://ergodox-ez.com/](https://ergodox-
ez.com/) but I’d love to hear of alternatives, especially if you have first
hand experience on them.

~~~
Asooka
Hi, I have experience both with the ergodox and the now-discontinued Truly
Ergonomic Computer Keyboard™. The TECK honestly has a slightly better layout
for me - the two halves are closer together and seem to fit my hands just a
bit better. On the downside, the TECK's hardware quality was atrocious with
keys double-pressing or missing presses after about a year of use. It also
uses its own microcontroller with its own closed-source firmware so there's
nearly no community around it. I'm not sure I can politely explain just how
much the TECK fails.

The ErgoDox on the other hand has been a joy to use for approximately a year
now and its design allowing for wasy swapping of keyswitches plus its open-
source firmware mean I have limitless customisability and am not stuck using
low-quality chinese cherry-mx clones (kailh). I hear they've actually improved
now, but the ones in the TECK were definitely subpar.

I use a split ortholinear keyboard because a standard layout keyboard makes my
fingers hurt after a while. ErgoDox and TECK(while it worked) were both good
enough for mitigating my problems while not being as exotic and unwieldy as a
kinesis.

I would love to try out a
[https://shop.keyboard.io/](https://shop.keyboard.io/) once (hopefully) the
price comes down a bit.

~~~
pault
As an avid mechanical keyboard hobbyist with an enormous collection of MX
variants (I have 10 ortholinear keyboards in various stages of construction in
my living room right now, and about 80 models of switches from various
manufacturers), I would argue that kailh had surpassed cherry in quality and
selection by a wide margin in recent years. You really should give them
another try.

------
tkinz27
I wonder if this will be useful for electron based editors like vscode's vim
plugin. I know the plugin is "good" but I always find something that works in
vim and doesn't in the plugin and end up going back to my terminal.

~~~
johnny22
I heard that you could embed neovim for that sort of thing, since neovim has
an ipc. I don't know how well the feature is maintained though.

~~~
rdrey
I recently found Oni, which aims to be a web-tech UI for neovim. (The new
version should even support the full VSCode extension API / ecosystem)
[https://github.com/onivim/oni2](https://github.com/onivim/oni2)

------
webvimbeta
The timing on this is really interesting for me. I've been working on a full
web vim product (plugins, multi-session, cloud storage, backup, etc.) and I'm
pretty close to a beta product (POC is fully functional, just polishing a few
rough edges). If anyone is interested in hearing more, email me at
webvimbeta@gmail.com

------
hq6
Running on Firefox and `Shift` generates a `^P` character.

~~~
lone_haxx0r
Same here, Firefox on Ubuntu 16.04.

------
jsturges
Not sure if it's a bug or user error (not sure if writing is supposed to be
supported yet), but after doing the following, the page becomes nonresponsive:

:o test.tx :wq I get an fsync failed error and I'm told to press enter or type
a command to continue.

I can't do either.

------
positr0n
I am impressed that

    
    
        :imap jk <Esc>
        :imap kj <Esc>
    

works great. However it seems like outer and inner text objects aren't working
at all. E.g. daw, ci)

~~~
fxfan
is this a common key binding? I've seen it before and it makes a lot of sense
but I'm wondering if I will run into issues. I don't want to disrupt my flow
and muscle memory and later regret it.

~~~
govg
Unless you type a lot of graph algorithms notes (and have to write
"Dijkstra"), you rarely encounter the key sequence jk. It makes it easier to
work with vim and never move to hit the Esc key.

~~~
irishsultan
That or you're writing in Dutch. Neither of ij, jk or even kj work in Dutch,
because they are very common.

~~~
govg
That's a very fair point! I hadn't considered this at all, I mostly write in
English, and subconsciously assumed this would be true of most Vim users.

------
tinus_hn
Perhaps it’s because I block web fonts but once I start typing little turds
remain where the intro text was.

~~~
chapium
why do you block webfonts?

~~~
woogley
Same reason people block Google Analytics or Facebook Like buttons. Many fonts
are hosted by fonts.google.com

------
mshockwave
:! cat /etc/passwd

[blocked]

sorry can't help myself trying this. but good job!

~~~
irth
It runs client side, though

~~~
metalliqaz
It's nice when tools prevent you from pwning yourself :)

------
khorpy
I see many comments on broken key combinations. Obviously, we need to somehow
overcome a UI/UX limitations of the applications that run inside a browser if
we're moving into browsers with the consumer apps. I wrote a dedicated article
on this: [https://database.blog/trello-hot-
keys/](https://database.blog/trello-hot-keys/)

------
yjhoney
sorry for being dense, but I can't seem to save files or do anything seemingly
practical. Is there any practical use cases for this library, or is this
purely along the lines of "Hey checkout this cool hack!"

~~~
boothby
When I was working on the Sage Notebook, circa 2007, I made the best textarea-
IDE I could... folks requested vim and emacs bindings but browsers just
weren't ready. Heck, I wrote my own javascript console because iirc only
Firefox had one at the time, I digress... I look forward to a vim plugin for
the IPython notebook!

~~~
_bohm
I used this back in the day and it worked pretty well. Not sure how it
cooperates with the newer Jupyter makeover but worth a shot!

[https://github.com/lambdalisue/jupyter-vim-
binding](https://github.com/lambdalisue/jupyter-vim-binding)

------
zeptomu
My test for "non-native" Vim is always 'q:' which should open a command line
window of previous commands at the bottom of your screen - unfortunately that
does not work.

Furthermore I can't use 'Ctrl-v' that let's you select a column of text (EDIT:
correction, this _does_ work).

'q:' should not be captured by the browser? Nevertheless impressive work.

~~~
tjoff
ctrl+v works fine for me (firefox windows)

~~~
zeptomu
It does not work for me on Firefox/Fedora (EDIT: it _does_ ). However 'q:'
still does nothing.

------
cyansmoker
<ctrl-w>w closed my browser window. Should have seen this one coming.

------
rvalue
I was hoping :w with filename would download the contents :D

------
steve19
Unfortunately it's not working on my android phone with hacker keyboard (full
keyboard with esc). There are also horizontal lines across the screen that
should not be there.

------
z92
Good work. Almost there.

Things that doesn't work starts from where you might need to change word
"ciw", visually select word "viw".

------
idoco
My take on vim web version: [http://exitvim2.win](http://exitvim2.win)

------
jhare
Now I really can't quit the internet

------
bhaak
Trying to save errors out with "E667: Fsync failed" and then it gets stuck.

------
jodrellblank
How do Emscripten cross-compiled things and WASM compiled things handle the
display? Is it a framebuffer they blindly draw to, do they need shim layers
added to interpret normal output to window-scaled in-browser output?

~~~
bbayer
In this example, author implements custom UI layer as it is described in
readme "WebAssembly frontend for Vim is implemented as a new GUI frontend".
Input and output is handled in JS side but core functionality resides on
WebAssembly part. I am not familiar with Vim but probably I/O is well
seperated from logic code so it might be easier to modify it to work on
browser but I actually don't know how it is working for other applications.

------
viksit
Also see previous discussion about the code on the GitHub repo
[https://news.ycombinator.com/item?id=17487936](https://news.ycombinator.com/item?id=17487936)

------
mises
Any plug-in support? Could I upload my vimrc to a server, then download it,
apply it, and run :PlugInstall to get my vim setup in any web browser?

~~~
masukomi
where would it store your plugins?

this is vim running in your browser, not some weird hybrid server-side vim
thing that stores all your config files and plugins server-side in a per-user
account but then transpiles them to wasm (regardless of plugin language) and
sends them to the browser.

------
taf2
very cool, some of the set commands don't seem to work for me... set
softtabstop for example didn't appear to work. also i might have a local
setting but tab complete with set wasn't working... again probably local
settings. and :w wtf didn't work :D seems to crash it. This is super cool

[update] ah i see from the readme write support is in the todo list.

------
fouc
Why does it completely freeze on :w foo ? It asks for ENTER or any key but
that doesn't work at all at that point.

------
curioussavage
pretty fun as an experiment. It would be so cool if someday github/gitlab had
this as an option for editing files

~~~
opan
I think this is why a lot of people still handle issues via email. It
integrates well with the classic text editors.

------
tedmiston
On mobile I see a blank gray page. Perhaps this only works on desktop
browsers. I still have no idea what it is.

~~~
chapium
I imagine vim wouldn't be very optimized for mobile.

~~~
tedmiston
When I clicked on the post, I figured it would be some sort of vim plugin etc.
Hopefully they can update the site to show a banner or some indication saying
what the site is (vim in a browser?) and that it doesn't support mobile
browsers.

------
ww520
Think I crashed it. Did a :w foobar and got an error and the page was stuck,
with the computer fan ramped up.

------
sabujp
i had to turn off adblock plus and ublock origin to get this to work for some
reason

------
fouc
Will wasm ever use html/css properly? Or will it just be more like flash?

~~~
jillesvangurp
It can already interact with the dom and people are working on making this
more seamless and faster.

The real question would be: why would you do that when you can instead use any
proper native UI toolkit?

Answer: it's now a choice. If you need command line stuff like vi running
smoothly in a browser, the DOM is an obstacle, not a solution. If on the other
hand you want a wasm application driving the DOM and generally looking and
feeling like a web app, you can do that as well. There are several frameworks
emerging for rust, kotlin, C#, and other languages that do exactly that and
that use bindings for the DOM and other APIs you have in javascript in a
browser. Basically, you are writing normal dom/html/css based applications;
except it all compiles down to wasm and does not involve any javascript.

------
lone_haxx0r
I can't save.

:w test

"test" E667: Fsync failed Warning: original file may be lost or damaged.

------
yitchelle
:q! is not working! Help, I can't exit.

But seriously, this is great work.

------
odiroot
Try inputting some diacritics, it breaks spectacularly.

Just tried ą ę ł etc ;)

------
vldr
Next step will be to bundle this in an electron app.

------
linsomniac
Does this get us any closer to being able to edit text fields using vi
keybindings? I've tried some of the plugins (long ago) and was underwhelmed
with the experience.

~~~
mdtusz
Try out qutebrowser. Still some shortcomings, but I've switched to it for
daily use.

------
SuMu2600
Is there a good iOS port of Vim available?

~~~
Terretta
iVim by Boogaloo

[https://github.com/terrychou/iVim](https://github.com/terrychou/iVim)

------
mikorym
What is the use case for this?

------
User23
Vi, the original roguelike.

------
tomrod
This is so cool! Well done!

------
sureaboutthis
Why was wasm used for this? It's not a javascript replacement as stated by
webassembly.org.

~~~
coolreader18
Because it's a pure port of Vim, which is written in C.

------
netmonk
How can i save a file ?

------
diehunde
Lol. Why no :Explore?

------
exabrial
Fucking touchbar.

------
chris_wot
Don't do :wq

~~~
kurtisc
Or try to change splits

------
hjk05
Sounds like a great fun little project. Shame it doesn’t work.

------
vmarovic
diw or ciw doesn't seem to work :(

------
nunobrito
Looks good!

How can I close it?

